当前位置: 首页 > 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.lryc.cn/news/536399.html

相关文章:

  • K8S容器启动提示:0/2 nodes are available: 2 Insufficient cpu.
  • LabVIEW外腔二极管激光器稳频实验
  • 笔记6——字典dict(dictionary)
  • 【MySQL】InnoDB单表访问方法
  • APP端网络测试与弱网模拟!
  • 【个人开发】deepseed+Llama-factory 本地数据多卡Lora微调
  • Redis7.0八种数据结构底层原理
  • Kafka 高吞吐量的底层技术原理
  • CCFCSP第34次认证第一题——矩阵重塑(其一)
  • 网络工程师 (35)以太网通道
  • O1、R1和V3模型
  • Linux 安装 Ollama
  • docker配置国内源
  • 【leetcode】关于循环数组的深入分析
  • DeepSeek 指导手册(入门到精通)
  • 【力扣题解】【76. 最小覆盖子串】容易理解版
  • Android10 音频参数导出合并
  • 在 Windows 系统中如何快速进入安全模式的两种方法
  • 计算机网络(1)基础篇
  • 自然语言处理NLP入门 -- 第四节文本分类
  • 【redis】数据类型之bitmaps
  • 计算机网络-MPLS转发原理
  • 5. 【.NET 8 实战--孢子记账--从单体到微服务--转向微服务】--微服务基础工具与技术--Nacos
  • 【每日关注】科技圈重要动态
  • 【算法】用C++实现A*算法
  • 细胞计数专题 | LUNA-FX7™新自动对焦算法提高极低细胞浓度下的细胞计数准确性
  • 记一次Self XSS+CSRF组合利用
  • JVM 类加载子系统在干什么?
  • Golang轻松实现消息模板变量替换:text/template
  • DeepSeek模型R1服务器繁忙,怎么解决?