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

Linux 下载 (Debian)

PostgreSQL 默认情况下在所有 Debian 版本中都可用。但是,Debian 会“快照”特定版本的 PostgreSQL,然后在该 Debian 版本生命周期内对其进行支持。PostgreSQL 项目维护了一个 Apt 仓库,其中包含所有受支持的 PostgreSQL 版本。

包含在发行版中

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

apt install postgresql

PostgreSQL Apt 仓库

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

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

  • trixie (13.x)
  • bookworm (12.x)
  • bullseye (11.x)
  • forky (testing)
  • sid (unstable)

在以下架构上

  • amd64
  • arm64
  • ppc64el

自动仓库配置

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 语言后端开发的库和头文件