Skip to main content
Documents
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

PostgreSQL 安装

安装 PostgreSQL 18 基础包

官方文档:Linux downloads (Red Hat family)

运维环境:

  • 操作系统:AlmaLinux 9.6
  • 数据库版本:PostgreSQL 18
# 因为 HTTP代理 的问题, 不要用 sudo, 使用 root 用户执行
sudo su - root

# 安装 Perl 模块
dnf install -y --enablerepo=crb perl-IPC-Run

# 设置代理
export http_proxy=http://127.0.0.1:1080;export https_proxy=http://127.0.0.1:1080;

# 添加 PostgreSQL 仓库
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# 禁用所有 PostgreSQL 模块
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/pgdg-redhat-all.repo

# 关闭所有 PostgreSQL 模块
dnf -qy module disable postgresql

# 安装 PostgreSQL 18 基础包
dnf uninstall -y postgresql17 postgresql17-devel postgresql17-libs
dnf install -y --enablerepo=pgdg18 postgresql18 postgresql18-devel postgresql18-libs