Linux 下载(Debian)

所有 Debian 版本默认都包含 PostgreSQL。但是,Debian 会“快照”一个特定版本的 PostgreSQL,该版本在 Debian 版本的整个生命周期内受到支持。PostgreSQL 项目维护了一个 Apt 仓库,提供所有受支持的 PostgreSQL 版本。

发行版自带

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

apt install postgresql

PostgreSQL Apt Repository

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

PostgreSQL Apt Repository 支持以下 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://www.postgresql.org/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 Repository Wiki 页面

软件包

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

postgresql-client-18 客户端库和客户端程序
postgresql-18 核心数据库服务器
postgresql-doc-18 文档
libpq-dev C 语言前端开发库和头文件
postgresql-server-dev-18 C 语言后端开发库和头文件