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
相关推荐
QQ27402875620 分钟前
BlockMesh Ai项目 监控节点部署教程
运维·服务器·web3
belldeep20 分钟前
WSL 安装 Debian 12 后,Linux 如何安装 vim ?
linux·debian·vim
wqqqianqian1 小时前
国产linux系统(银河麒麟,统信uos)使用 PageOffice自定义Word模版中的数据区域
linux·word·自定义·pageoffice·数据区域
南棱笑笑生1 小时前
20250512给NanoPi NEO core开发板在Ubuntu core20.04系统更新boot.img
linux·运维·ubuntu
XMYX-01 小时前
Linux du 命令终极指南:从基础到精通
linux·服务器
小锋学长生活大爆炸1 小时前
【教程】Docker更换存储位置
运维·docker·容器
DourPanda2 小时前
polarctf-web-[rce1]
linux·网络协议·网络安全
愚润求学2 小时前
【Linux】动静态库链接原理
linux·运维·服务器·开发语言·笔记
云攀登者-望正茂2 小时前
无缝部署您的应用程序:将 Jenkins Pipelines 与 ArgoCD 集成
运维·jenkins·argocd
wingaso3 小时前
[经验总结]删除gitlab仓库分支报错:错误:无法推送一些引用到“http:”
linux·数据仓库·git