The psql command-line tool is a terminal-based frontend to PostgreSQL. It is
required by the gcloud beta alloydb
connect command and is useful for
direct database connections.
PostgreSQL has a wide
range of installation options. This page describes how to install psql on
macOS, Linux, and Windows.
macOS
To install psql on macOS, we recommend using Homebrew.
- Install the
postgresqlpackage:
brew install postgresql
- Add
psqlto yourPATHby following the instructions provided in the terminal output after the installation completes. For example:
echo 'export PATH="/opt/homebrew/opt/postgresql@18/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Linux (Debian / Ubuntu)
Use your distribution's package manager to install the PostgreSQL client.
sudo apt-get update
sudo apt-get install postgresql-client
For other distributions, see the official PostgreSQL download page.
Windows
To install psql on Windows, you can use the interactive installer.
Installer
- Download the PostgreSQL Interactive Installer for Windows from the PostgreSQL downloads page.
- Run the installer. When prompted to select components, you can install only Command Line Tools.
- Add the
bindirectory of your PostgreSQL installation (for example,C:\Program Files\PostgreSQL\18\bin) to your systemPATHenvironment variable.
Verify the installation
After installation, verify that psql is in your PATH and is working
correctly:
psql --version
If installed correctly, the output shows the version of the psql client
tool.