# 使用 Homebrew, apk, dnf, apt, Nix 安装 libpq

查看 libpq 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:libpq
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install libpq
```

  证据: local Homebrew formula metadata

### Linux

- apk (92%):

```sh
sudo apk add libpq
```

  证据: Alpine Linux edge package indexes: libpq from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz

- dnf (92%):

```sh
sudo dnf install libpq
```

  证据: Fedora Rawhide package metadata: libpq from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst

- Debian apt (92%):

```sh
sudo apt install pg-checksums-doc
```

  证据: Debian stable package indexes: pg-checksums-doc from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- Nix (92%):

```sh
nix profile install nixpkgs#pg_checksums
```

  证据: nixpkgs package indexes: pkgs/by-name/pg/pg_checksums/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

## 软件包事实

- **软件包键:** brew:libpq
- **软件包管理器:** Homebrew
- **版本:** 18.4
- **来源摘要:** Postgres C API library
- **主页:** <https://www.postgresql.org/docs/current/libpq.html>
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- clusterdb (别名)
- createdb (别名)
- createuser (别名)
- dropdb (别名)
- dropuser (别名)
- ecpg (别名)
- initdb (别名)
- pg_amcheck (别名)
- pg_archivecleanup (别名)
- pg_basebackup (别名)
- pg_checksums (别名)
- pg_combinebackup (别名)
- pg_config (别名)
- pg_controldata (别名)
- pg_createsubscriber (别名)
- pg_ctl (别名)
- pg_dump (别名)
- pg_dumpall (别名)
- pg_isready (别名)
- pg_receivewal (别名)
- pg_recvlogical (别名)
- pg_resetwal (别名)
- pg_restore (别名)
- pg_rewind (别名)
- pg_test_fsync (别名)
- pg_test_timing (别名)
- pg_upgrade (别名)
- pg_verifybackup (别名)
- pg_waldump (别名)
- pg_walsummary (别名)
- pgbench (别名)
- psql (别名)
- reindexdb (别名)
- vacuumdb (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 18.4
## 项目历史与用法

libpq is PostgreSQL's C client library: the small, stable-looking surface that lets C programs connect to PostgreSQL servers, submit queries, and read results. It also underlies several other PostgreSQL client interfaces, so packaging it separately gives developers the client headers, shared library, and familiar tools without requiring a Homebrew PostgreSQL server installation.

### 项目历史

PostgreSQL descends from the Berkeley POSTGRES project, whose implementation began in 1986. The Postgres95 transition in 1994 replaced POSTQUEL with SQL and introduced `psql`; the PostgreSQL name arrived in 1996 to connect the POSTGRES heritage with SQL support.

The PostgreSQL manual notes that the `libpq` name came from PostQUEL. As PostgreSQL matured into a long-lived open source database, libpq became the canonical C API for client programs and a shared substrate for other language bindings and command-line clients.

### 采用历史

libpq's adoption follows PostgreSQL's adoption: applications, drivers, migration tools, backup tools, and admin scripts need a PostgreSQL client layer even when the database server runs elsewhere. PostgreSQL's 2023 project announcement described the system as benefiting from more than 25 years of open source development and a global community of users, contributors, companies, and organizations.

Homebrew's `libpq` formula packages the client side as a keg-only formula. That matters on developer workstations because it avoids colliding with a full `postgresql` formula while still making `psql`, `pg_dump`, `pg_restore`, `pg_config`, and the C library available to builds and scripts.

### 使用方式

Typical package-manager use is installing libpq so native extensions, database drivers, and command-line workflows can compile or run against PostgreSQL. Developers use `pg_config` to find build flags, `psql` for interactive sessions, and the dump/restore utilities for movement between PostgreSQL instances.

### 为什么软件包爱好者会关心

libpq is package-nerd significant because it is a dependency edge disguised as a database client. Many packages need PostgreSQL client headers and link libraries, but users often do not want a local database server; a separate formula keeps that dependency smaller and less invasive.

It also exposes PostgreSQL's major-version reality to package managers: client utilities can speak across versions, but dump, restore, upgrade, and extension-building workflows often care about exact major lines. That is why versioned formulae such as `libpq@16` and `libpq@17` are useful beside the unversioned formula.

### 时间线

- 1986: Implementation of the Berkeley POSTGRES project began at the University of California at Berkeley.
- 1994: Postgres95 added an SQL interpreter and `psql`, replacing POSTQUEL and the older monitor program.
- 1996: The project adopted the PostgreSQL name and reset version numbering to 6.0.
- 2023-09-14: PostgreSQL 16 was released, including libpq load-balancing support among its client-side changes.
- 2024-09-26: PostgreSQL 17 was released with new client and administration utilities including `pg_createsubscriber` and `pg_combinebackup`.

### Related projects

- PostgreSQL server, `psql`, ECPG, PostgreSQL client utilities, language drivers that use libpq, and Homebrew's versioned `libpq@16` and `libpq@17` formulae are the closest related projects.

### 来源

- <https://formulae.brew.sh/formula/libpq>
- <https://www.postgresql.org/about/news/postgresql-16-released-2715/>
- <https://www.postgresql.org/about/press/presskit17/>
- <https://www.postgresql.org/docs/current/history.html>
- <https://www.postgresql.org/docs/current/libpq.html>
- <https://www.postgresql.org/support/versioning/>


## 安全说明

没有找到 libpq 的匹配本地密钥处理 manifest。Nucleus 软件包元数据仍在此发布，以便未来覆盖拥有稳定的软件包 URL。



## Configuration and credential file locations

These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.


## Configuration files

- Unix: psqlrc in the directory reported by pg_config --sysconfdir, ~/.psqlrc, pg_service.conf in the directory reported by pg_config --sysconfdir, ~/.pg_service.conf
- Windows: %APPDATA%\postgresql\psqlrc.conf, %APPDATA%\postgresql\.pg_service.conf

## Credential files

- Unix: ~/.pgpass
- Windows: %APPDATA%\postgresql\pgpass.conf
## 其他软件包管理器记录

- apk - libpq - 18.4-r0: normalized package name match | Alpine Linux edge package indexes: libpq from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | PostgreSQL client library | https://www.postgresql.org/
- dnf - libpq - 18.4-4.fc45: normalized package name match | Fedora Rawhide package metadata: libpq from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | PostgreSQL client library | http://www.postgresql.org/
- dnf - libpq-devel - 18.4-4.fc45: normalized package name match | Fedora Rawhide package metadata: libpq-devel from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | Development files for building PostgreSQL client tools | http://www.postgresql.org/
- Debian apt - pg-checksums-doc - 1.2-2: installed executable or alias match | Debian stable package indexes: pg-checksums-doc from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Activate/deactivate/verify PostgreSQL data checksums (Documentation) | https://github.com/credativ/pg_checksums
- Debian apt - postgresql-17-pg-checksums - 1.2-2: installed executable or alias match | Debian stable package indexes: postgresql-17-pg-checksums from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Activate/deactivate/verify PostgreSQL data checksums | https://github.com/credativ/pg_checksums
- Nix - pg_checksums: installed executable or alias match | nixpkgs package indexes: pkgs/by-name/pg/pg_checksums/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- Ubuntu apt - pg-checksums-doc - 1.1-6: installed executable or alias match | Ubuntu 24.04 LTS package indexes: pg-checksums-doc from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | Activate/deactivate/verify PostgreSQL data checksums (Documentation) | https://github.com/credativ/pg_checksums
- Ubuntu apt - postgresql-16-pg-checksums - 1.1-6: installed executable or alias match | Ubuntu 24.04 LTS package indexes: postgresql-16-pg-checksums from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | Activate/deactivate/verify PostgreSQL data checksums | https://github.com/credativ/pg_checksums


## Combined YAML source

View the package source record on GitHub. [combined/libpq.yml](https://github.com/mxcl/pkgdb/blob/main/combined/libpq.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated configuration and credential file locations
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
