当前位置: 首页 > news >正文

ubuntu安装PostgreSQL

1、安装数据库

# 更新软件包列表并安装
sudo apt update
sudo apt install postgresql postgresql-contrib -y

  # 安装特定版本(以PostgreSQL 14为例)
  sudo apt install postgresql-14 postgresql-client-14 -y

2、远程访问

文件类型    默认路径(PostgreSQL 14)
主配置文件    /etc/postgresql/14/main/postgresql.conf
访问控制文件    /etc/postgresql/14/main/pg_hba.conf

  # 修改postgresql.conf
  listen_addresses = '*' # 允许所有IP连接

  # 修改pg_hba.conf添加规则
  host all all 0.0.0.0/0 md5

  重启服务

   sudo systemctl restart postgresql

3、修改默认密码

# 切换到postgres系统用户
sudo -i -u postgres
psql

-- 登录后修改密码
ALTER USER postgres PASSWORD '新密码';
 

4、命令

# 启动服务
sudo systemctl start postgresql# 停止服务
sudo systemctl stop postgresql# 重启服务
sudo systemctl restart postgresql# 重新加载配置(不重启)
sudo systemctl reload postgresql
# 查看服务状态
sudo systemctl status postgresql# 查看详细状态信息
sudo systemctl status postgresql -l# 查看服务是否开机自启
sudo systemctl is-enabled postgresql# 查看服务是否正在运行
sudo systemctl is-active postgresql

# 启用开机自启动
sudo systemctl enable postgresql# 禁用开机自启动
sudo systemctl disable postgresql# 立即启用并启动服务
sudo systemctl enable --now postgresql# 重新启用服务
sudo systemctl reenable postgresql
 

 

http://www.jsqmd.com/news/140225/

相关文章:

  • 微信小程序uniapp-vue运动健身户外运动体能训练系统
  • 2025年华南师范大学计算机考研复试机试真题(附 AC 代码 + 解题思路)
  • 基于SpringBoot的海洋环保小程序系统(毕业设计项目源码+文档)
  • 微信小程序uniapp-vue音乐播放器
  • 靠谱的口碑靠前不踩雷大落地窗品牌杰出生产厂家
  • 12月25日记
  • 方达炬 发明一批指标
  • C语言(一)
  • 微信小程序uniapp-vue自驾游资助定制游旅游线路景点评论系统
  • Linux Kernel (一) 计算机启动流程简述
  • 【图像处理基石】什么是神经渲染?
  • 微信小程序uniapp-vue英语学习小助手的设计
  • 1.1 一维数组(markdown版)
  • 基于SpringBoot的公司财务预算管理系统(毕业设计项目源码+文档)
  • HBase与Jupyter:交互式数据分析
  • 基于SpringBoot的顾客偏好的唯品会推荐系统设计与实现(毕业设计项目源码+文档)
  • AI生成系统架构图 告别系统架构图制作焦虑!AI一键生成,小白也能秒变高手
  • 为什么 Go 没有依赖注入和 Bean 机制?语言设计哲学对比 - 若
  • 案例:扩容数据免迁移方案
  • 基于SpringBoot的果蔬仓储管理系统的设计与实现(毕业设计项目源码+文档)
  • 可持续发展目标对公司估值的长期影响
  • Java-Spring Bean 自动启动机制详解 - 从原理到实践 - 若
  • 数字
  • 12月24日日记
  • 昇腾 NPU 环境下 GPT-2 模型本地部署全指南(含踩坑排错)
  • 《具身智能》读书笔记
  • PhysicReviewsNotes
  • 2025最新!专科生必看9大AI论文平台测评与推荐
  • 150_尚硅谷_数组应用实例(2)
  • 大一职业规划