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
相关推荐
乌托邦的逃亡者1 分钟前
Dockerfile的配置和使用
linux·运维·docker·容器
小此方3 分钟前
Re:Linux系统篇(三)指令篇 · 二:十二个高频指令精讲+重定向操作+“一切皆文件“深入理解
linux·运维·服务器
十五年专注C++开发8 分钟前
MobaXterm:Windows 远程工作全能工具箱
linux·windows·mobaxterm
wohehe13 分钟前
Android项目工程化-Github Actions
linux·github
用户1401056775191 小时前
线上接口偶发超时,最后发现是 conntrack 打满:一次网络故障排查实战
运维
以太浮标1 小时前
华为eNSP模拟器综合实验之- 主机没有配置缺省网关时,通过路由式Proxy ARP实现通信(arp-proxy enable)
运维·网络·网络协议·华为·智能路由器·信息与通信
REDcker1 小时前
Linux disown命令详解 后台作业脱管与终端退出
linux·运维·chrome
cyber_两只龙宝1 小时前
【Oracle】Oracle之SQL的转换函数和条件表达式
linux·运维·数据库·sql·云原生·oracle
被摘下的星星2 小时前
四层模型TCP/IP协议栈
运维·服务器·网络
努力努力再努力wz2 小时前
【Linux网络系列】深入理解 I/O 多路复用:从 select 痛点到 poll 高并发服务器落地,基于 Poll、智能指针与非阻塞 I/O与线程池手写一个高性能 HTTP 服务器!(附源码)
java·linux·运维·服务器·c语言·c++·python