Install the standalone PostgreSQL command-line client (psql) on macOS, Windows, and Linux without deploying the full database server.
The psql CLI lets you connect to remote PostgreSQL servers, run SQL, and automate tasks without running a local database. This saves resources on developer machines and CI pipelines.
Most systems split PostgreSQL into server and client packages. Look for names like postgresql-client
, postgresqlXX-client
, or libpq
. Installing these pulls in psql and supporting libraries only.
Use Homebrew for the fastest setup:
$ brew install postgresql
Homebrew bundles both client and server. Skip brew services start postgresql
if you only need the client.
$ sudo apt-get update
$ sudo apt-get install postgresql-client
Add a major-version suffix (e.g., postgresql-client-15
) to match your production version.
$ sudo dnf install postgresql
# or specific version
$ sudo dnf install postgresql15
Older systems use yum
instead of dnf
.
Download the "psql Client only" option from EDB installers or install via chocolatey
:
PS> choco install postgresql
During the GUI installer, uncheck "Stack Builder" if you don’t need extras.
$ psql --version
psql (PostgreSQL) 15.3
A version string confirms psql is on your PATH.
$ psql -h db.example.com -U app_user -d app_db -p 5432
The -W
flag prompts for a password interactively.
Store connection parameters in ~/.pgpass
or environment variables to avoid exposing passwords in shell history. Use psqlrc
for prompt and output tweaks.
Yes. Removing postgresql
server packages will not affect libpq
or psql
when installed separately.
See the FAQ section below for PATH issues, SSL errors, and version mismatches.
The installer didn’t add psql to your PATH. Re-open your terminal or add /usr/pgsql-XX/bin
(Linux) or C:\Program Files\PostgreSQL\15\bin
(Windows) to PATH.
Yes. psql works with any PostgreSQL-compatible host. Supply the hostname, port, user, and database exactly as provided by the cloud provider.
Use ~/.pgpass
(600 permissions) or PGPASSWORD
environment variable in CI. Avoid plain text in shell history.