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

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.kler.cn/a/542929.html

相关文章:

  • ubuntu如何设置停止程序自动更新
  • django配置跨域
  • 基础入门-HTTP数据包红蓝队研判自定义构造请求方法请求头修改状态码判断
  • 【AcWing】蓝桥杯辅导课-数学与简单DP
  • 7.推荐系统的评价与优化
  • Mybatis快速入门与核心知识总结
  • Prolog语言的云计算
  • 命令行参数和环境变量
  • git服务器搭建,gitea服务搭建,使用systemclt管理服务
  • c版的findcontours改写,输出为vector<vector<cPoint>>
  • Git在不同电脑上使用
  • 自学人工智能大模型,满足7B模型的训练和微调以及推理,预算3万,如何选购电脑
  • VSCode 如何使用 eslint
  • 基于 GEE 利用插值方法填补缺失影像
  • SMU Winter 2025 div1 2nd
  • PDF 文件的安全功能概述
  • Unity做2D小游戏4------让角色动起来
  • RDKit 给3D信息缺失的sdf生成三维结构
  • 黑马Redis详细笔记(实战篇---短信登录)
  • 电脑出现蓝屏英文怎么办?查看修复过程
  • 【物联网】电子电路基础知识
  • RocketMQ、RabbitMQ、Kafka 的底层实现、功能异同、应用场景及技术选型分析
  • 华为openEuler部署docker
  • CCFCSP第34次认证第一题——矩阵重塑(其一)
  • DeepSeek应用——与word的配套使用
  • 活动预告 | 解锁 Excel 新境界 —— AI 技术赋能下的数据分析超级引擎!