2025年9月25日: PostgreSQL 18 发布!

Linux 下载 (Ubuntu)

PostgreSQL 默认情况下在所有 Ubuntu 版本中都可用。但是,Ubuntu 会“快照”特定版本的 PostgreSQL,该版本将在该 Ubuntu 版本的整个生命周期内得到支持。PostgreSQL 项目维护着一个包含所有支持的 PostgreSQL 版本的 Apt 仓库

包含在发行版中

Ubuntu 默认包含 PostgreSQL。要在 Ubuntu 上安装 PostgreSQL,请使用 apt(或其他 apt 驱动的)命令

apt install postgresql

PostgreSQL Apt 仓库

如果您的 Ubuntu 版本中包含的版本不是您想要的,您可以使用 PostgreSQL Apt 仓库。该仓库将与您正常的系统和补丁管理集成,并在 PostgreSQL 的所有支持的 生命周期 内提供所有支持的 PostgreSQL 版本的自动更新。

PostgreSQL Apt 仓库支持以下 Ubuntu 的当前版本

  • questing (25.10, 非 LTS)
  • plucky (25.04, 非 LTS)
  • noble (24.04, LTS)
  • jammy (22.04, LTS)

支持以下架构

  • amd64
  • arm64 (仅限 LTS 版本)
  • ppc64el (仅限 LTS 版本)

自动化仓库配置

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

要手动配置 Apt 仓库,请遵循以下步骤

# Import the repository signing key:
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://postgresql.ac.cn/media/keys/ACCC4CF8.asc

# Create the repository configuration file:
. /etc/os-release
sudo sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main' > /etc/apt/sources.list.d/pgdg.list"

# Update the package lists:
sudo apt update
安装 PostgreSQL: (将“18”替换为您想要的版本)
sudo apt install postgresql-18

有关 apt 仓库的更多信息,包括常见问题的解答,请参阅 PostgreSQL Apt 仓库 wiki 页面

软件包

该仓库包含许多不同的软件包,包括第三方插件。最常用和最重要的软件包是 (根据需要替换版本号)

postgresql-client-18 客户端库和客户端二进制文件
postgresql-18 核心数据库服务器
postgresql-doc-18 文档
libpq-dev 用于 C 语言前端开发的库和头文件
postgresql-server-dev-18 用于 C 语言后端开发的库和头文件