Install the psql command line tool

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 .

  1. Install the postgresql package:
 brew  
install  
postgresql 
  1. Add psql to your PATH by 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

  1. Download the PostgreSQL Interactive Installerfor Windows from the PostgreSQL downloads page .
  2. Run the installer. When prompted to select components, you can install only Command Line Tools.
  3. Add the bin directory of your PostgreSQL installation (for example, C:\Program Files\PostgreSQL\18\bin ) to your system PATH environment 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.

What's next

Create a Mobile Website
View Site in Mobile | Classic
Share by: