Install the psql connection tool

The psql command line tool is widely used for interacting with a PostgreSQL or TimescaleDB instance, and it is available for all operating systems. Most of the instructions we give you assume you are using psql.

Before you start, check that you don't already have psql installed. It is sometimes installed by default, depending on your operating system and other packages you have installed over time:

Install psql on Apple macOS

The psql tool is installed by default on macOS systems when you install PostgreSQL, and this is the most effective way to install the tool. These instructions use the Homebrew package management tool.

Installing PostgreSQL on Apple macOS

  1. Install Homebrew, if you don't already have it:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    For more information about Homebrew, including installation instructions, see the [Homebrew documentation][homebrew].
  2. Make sure your Homebrew repository is up to date:
    brew doctor
    brew update
  3. Install PostgreSQL:
    brew install postgres

If you do not want to install the entire PostgreSQL package, you can install the psql tool on its own.

Installing psql on Apple macOS

  1. Install Homebrew, if you don't already have it:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    For more information about Homebrew, including installation instructions, see the [Homebrew documentation][homebrew].
  2. Make sure your Homebrew repository is up to date:
    brew doctor
    brew update
  3. Install psql:
    brew install libpq
  4. Update your path to include the psql tool.
    brew link --force libpq
    For your reference, on Intel chips, the symbolic link is added to /usr/local/bin. On Apple Silicon, the symbolic link is added to /opt/homebrew/bin.

Install psql on Debian and Ubuntu

You can use the apt package manager on Debian and Ubuntu systems to install the psql tool.

Installing psql on Debian and Ubuntu

  1. Make sure your apt repository is up to date:
    sudo apt-get update
  2. Install the postgresql-client package:
    sudo apt-get install postgresql-client

Install psql on Windows

The psql tool is installed by default on Windows systems when you install PostgreSQL, and this is the most effective way to install the tool. These instructions use the interactive installer provided by PostgreSQL and EnterpriseDB.

Installing psql on Windows

  1. Download and run the PostgreSQL installer from www.enterprisedb.com.
  2. In the Select Components dialog, check Command Line Tools, along with any other components you want to install, and click Next.
  3. Complete the installation wizard to install the package.

Found an issue on this page?

Report an issue!

Keywords

Related Content