How to Install psql on Mac, Ubuntu, Debian, Windows
Before You Start
Before you start, you should confirm that you don’t already have psql installed. In fact, if you’ve ever installed Postgres or TimescaleDB before, you likely already have psql installed.
Install on MacOS Using Homebrew
First, install the Brew Package Manager.
Second, update brew. From your command line, run the following commands:
brew doctor brew update brew install libpq
Finally, symlink psql (and other libpq tools) into
brew link --force libpq
Install on Ubuntu 16.04,18.04 and Debian 9,10
Install on Ubuntu and Debian using the
apt package manager:
sudo apt-get update sudo apt-get install postgresql-client
Note: This only installs the psql client and not the PostgreSQL database.
Install Windows 10
We recommend using the installer from PostgreSQL.org.
Last Step: Connect to Your PostgreSQL Server
Let’s confirm that psql is installed:
Now, in order to connect to your PostgreSQL server, we’ll need the following connection params:
- Database name
There are two ways to use these params.
psql -h [HOSTNAME] -p [PORT] -U [USERNAME] -W -d [DATABASENAME]
Once you run that command, the prompt will ask you for your password. (Which we specified with the
And this is how they look in the Timescale UI:
Congrats! Now you have connected via psql.
If you haven’t yet, you can head over to our documentation page and find out more about TimescaleDB, our open-source extension that makes PostgreSQL scalable.