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 in the Timescale documentation 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 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. On macOS you can use Homebrew or MacPorts to install the PostgreSQL package or just the psql
tool.
Installing PostgreSQL package using Homebrew
- Install Homebrew, if you don't already have it:For more information about Homebrew, including installation instructions, see the Homebrew documentation.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Make sure your Homebrew repository is up to date:
brew doctor brew update
- Install PostgreSQL:
brew install postgres
Installing PostgreSQL package using MacPorts
- Install MacPorts by downloading and running the package installer.. For more information about MacPorts, including installation instructions, see the MacPorts documentation.
- Install the latest version of Postgresql:For example, to install version 14 replace
sudo port install postgresql<xx>
postgresql<xx>
withpostgresql14
. - OPTIONAL View the files that were installed:
port contents postgresql<xx>
Installing psql on macOS
If you do not want to install the entire PostgreSQL package, you can install the psql
tool on its own. libpqxx
is the official C++ client API for PostgreSQL.
Installing psql using Homebrew
- Install Homebrew, if you don't already have it:For more information about Homebrew, including installation instructions, see the Homebrew documentation.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Make sure your Homebrew repository is up to date:
brew doctor brew update
- Install
psql
:brew install libpq
- Update your path to include the
psql
tool.On Intel chips, the symbolic link is added tobrew link --force libpq
/usr/local/bin
. On Apple Silicon, the symbolic link is added to/opt/homebrew/bin
.
Installing psql using MacPorts
- Install MacPorts by downloading and running the package installer. For more information about MacPorts, including installation instructions, see the MacPorts documentation.
- Install the latest version of libpqxx:
sudo port install libpqxx
- OPTIONAL View the files that were installed by libpqxx:
port contents libpqxx
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 using the apt package manager
- Make sure your
apt
repository is up to date:sudo apt-get update
- 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
- Download and run the PostgreSQL installer from www.enterprisedb.com.
- In the
Select Components
dialog, checkCommand Line Tools
, along with any other components you want to install, and clickNext
. - Complete the installation wizard to install the package.
Found an issue on this page?
Report an issue!Keywords