Ubuntu安装PgSQL17

参考官网教程,Ubuntu24 apt在线安装Postgres 17

1. 要手动配置 Apt 存储库

shell 复制代码
# 导入存储库签名密钥:
sudo apt install curl ca-certificates 
sudo install -d /usr/share/postgresql-common/pgdg 
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc 

# 创建存储库配置文件:
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' 

# 更新软件包列表:
sudo apt update 

# 安装最新版本的 PostgreSQL:
# 如果需要特定版本,请使用"postgresql-16"或类似版本'postgresql' 
sudo apt -y install postgresql-17

2. 启动服务

shell 复制代码
sudo systemctl start postgresql
sudo systemctl enable postgresql

3. 配置 PostgreSQL 17

shell 复制代码
编辑 postgresql.conf 通过将 listen_addresses 更改为 * 来允许远程连接
文件:/etc/postgresql/17/main/postgresql.conf
设置:listen_addresses = '*'

通过编辑 pg_hba.conf 将 PostgreSQL 配置为使用 md5 密码验证,如果您希望通过PGADMIN进行远程连接
文件:/etc/postgresql/17/main/pg_hba.conf
设置:host all all 0.0.0.0/0 md5

重启服务
sudo systemctl restart postgresql

4. 连接到 PostgreSQL

shell 复制代码
# 以 postgres 用户身份连接
sudo -u postgres psql

# 为 postgres 用户设置密码
ALTER USER postgres PASSWORD 'YOUR_PASSWORD';

参考链接:

  1. https://www.postgresql.org/download/linux/ubuntu/
  2. https://dev.to/johndotowl/postgresql-17-installation-on-ubuntu-2404-5bfi
相关推荐
ylscode16 小时前
Oracle 推出月度安全补丁新机制,首批紧急修复已覆盖 35 个高危漏洞
运维·网络·安全·安全威胁分析
http阿拉丁神猫16 小时前
TCP、IPv4和IPv6解读
运维·网络协议·tcp/ip
寺中人16 小时前
Linux系统超详细解析与零基础实战使用教程
linux·服务器·系统架构·linux命令·零基础教程
Android系统攻城狮17 小时前
Linux Pulseaudio深度解析之pa_stream_set_overflow_callback用流程与实战(三十七)
linux·运维·服务器·音频进阶·pulseaudio进阶
学无止境_永不停歇17 小时前
从零手写高性能C++ TCP 服务器框架(十一) --- Connection实现
linux·服务器·网络·c++
云智慧AIOps社区17 小时前
直击BEYOND Expo 2026 | 云智慧Cloudwise亮相澳门,发布“三层战略”护航 AI 数实共生
运维·人工智能·运维自动化·ai基础设施可靠性
AOwhisky17 小时前
MySQL 学习笔记(第二期):SQL 语言之库表操作与数据类型
linux·运维·数据库·笔记·sql·学习·mysql
鲨鱼辣椒喔17 小时前
# 团队密码管理工具怎么选?对比 Bitwarden、Vault、Excel 和 OpsTiny
运维·数据库·安全·密码学·个人开发
fangdengfu12317 小时前
jenkins使用pipeline实现滚动发布
运维·jenkins