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

Ubuntu安装PgSQL17

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

1. 要手动配置 Apt 存储库

# 导入存储库签名密钥:
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. 启动服务

sudo systemctl start postgresql
sudo systemctl enable postgresql

3. 配置 PostgreSQL 17

编辑 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

# 以 postgres 用户身份连接
sudo -u postgres psql# 为 postgres 用户设置密码
ALTER USER postgres PASSWORD 'YOUR_PASSWORD';# 退出exit;

参考链接:

  1. https://www.postgresql.org/download/linux/ubuntu/
  2. https://dev.to/johndotowl/postgresql-17-installation-on-ubuntu-2404-5bfi

http://www.mrgr.cn/news/90245.html

相关文章:

  • 嵌入式音视频开发(一)ffmpeg框架及内核解析
  • 擎天柱例程35 串口绘图
  • 2025-2-10-4.4 双指针(基础题1)
  • elementplus 使用日期时间选择器,设置可选范围为前后大于2年且只能选择历史时间不能大于当前时间点
  • 【大数据安全分析】为什么要用大数据技术进行安全分析?
  • 2025年前端面试题~ 【前端面试】更新
  • 教程 | MySQL 基本指令指南(附MySQL软件包)
  • 基于Kotlin中Flow扩展重试方法
  • 【HarmonyOS Next 自定义可拖拽image】
  • 【生产变更】- 12c及以后 ADG主备切换
  • 2.10学习总结
  • 从零复现DeepSeek R1:从V3中对MoE、MLA、MTP的实现,到Open R1对R1中SFT、GRPO的实现
  • 【Java】多线程和高并发编程(四):阻塞队列(上)基础概念、ArrayBlockingQueue
  • Vue.js 状态管理库Pinia
  • C++类和对象进阶:构造函数和析构函数详解
  • linux部署node服务
  • 使用ThreeJS实现的宇宙大爆炸3D粒子特效思路,原理和关键代码解析
  • 达梦数据库(DM)线程管理
  • 【Java】多线程和高并发编程(三):锁(中)深入ReentrantLock
  • C++ STL汇总