TigerData logo
TigerData logo
  • Timescale
  • Products
  • Customers
  • Developers
  • Pricing
Contact usLog InTry for free

Products

Time Series and Analytics AI and Vector Enterprise Plan Cloud Status Support Security Cloud Terms of Service

Learn

Documentation Blog Forum Tutorials Changelog Success Stories Time Series Database

Company

Contact Us Careers About Brand Community Code Of Conduct Events

Subscribe to the TigerData Newsletter

By submitting, you acknowledge TigerData's Privacy Policy

2025 (c) Timescale, Inc., d/b/a TigerData. All rights reserved.

Privacy preferences
LegalPrivacySitemap

Categories

All posts

AI

Analytics

Announcements & Releases

Benchmarks & Comparisons

Data Visualization

Developer Q&A

Engineering

General

IoT

Open Source

PostgreSQL

PostgreSQL Performance

PostgreSQL Tips

State of PostgreSQL

Time Series Data

Tutorials

PostgreSQL for time series and events

Engineered for powerful price-performance and speed.

Learn more about TigerData

Category: All posts

Tutorials

Jun 11, 2025

How to Install psql on Mac, Ubuntu, Debian, Windows

A fierce PostgreSQL elephant (How to Install psql on Mac, Ubuntu, Debian, Windows)

Posted by

Ajay Kulkarni

Ajay Kulkarni

01

Before You Start

02

Install on MacOS Using Homebrew

03

Install on Ubuntu 23.10,22.04 and Debian 12

04

Install Windows 10

05

Last Step: Connect to Your PostgreSQL Server

06

Related resources: psql + Postgres

07

About TimescaleDB and PostgreSQL Queries

08

FAQs: How to Install psql on Mac, Ubuntu, Debian, Windows

psql is a terminal-based front-end to PostgreSQL. It provides an interactive command-line interface to the PostgreSQL (or TimescaleDB) database. With psql, you can type in queries interactively, issue them to PostgreSQL, and see the query results. It also provides several meta-commands and various shell-like features to facilitate writing scripts and automating a wide variety of tasks.

For instance, users can create, modify, and delete database objects such as tables, views, or users using psql. They can also execute SQL commands, manage data within the database, and even customize the psql environment.

Since psql is the standard command line interface for interacting with a PostgreSQL or TimescaleDB instance, this article will show you how to install it on a variety of operating systems.

💡
Need a refresher on Postgres and psql commands? Check out our Postgres Cheat Sheet.

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.

To verify it, open the command line program and type the following:

psql --version

If you haven’t installed psql, here is how to install it on a variety of operating systems.

💡
Forgot how to connect to your Postgres services? You can use the .pg_service.conf file, or if you're a TimescaleDB user, just click one button.

Install on MacOS Using Homebrew

  1. First, install the Brew Package Manager. Homebrew, often called "brew," is a free and open-source software package management system that simplifies software installation on Apple's macOS operating system and Linux.

Homebrew downloads, unpacks, and installs the software and its dependencies in your system. It also keeps track of what it has installed, allowing you to easily uninstall software or upgrade to newer versions when they become available.

  1. Second, update brew. From your command line, run the following commands:
brew doctor
brew update
brew install libpq

Next, you will have to symlink psql. Symlinking, or creating a symbolic link, is a process in Unix or Unix-like operating systems (like MacOS) that creates a link to a file or a directory that resides elsewhere in the system. Symbolic links are similar to shortcuts in Windows.

  1. The final step is to symlink psql (and other libpq tools) into /usr/local/bin:
brew link --force libpq
⭐
Related documentation: Installing self-hosted TimescaleDB on macOS.

Install on Ubuntu 23.10,22.04 and Debian 12

Install on Ubuntu and Debian using the apt package manager:

sudo apt update
sudo apt install postgresql-client

Note: This only installs the psql client and not the PostgreSQL database.

💡
Editor's Note: For information about how to connect psql to your TimescaleDB database, please refer to Tiger Data documentation on connecting to your database with psql.

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:

psql --version

Now, in order to connect to your PostgreSQL server, we’ll need the following connection params:

  • Hostname
  • Port
  • Username
  • Password
  • Database name

There are two ways to use these params.

Option 1:

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 -W flag.)

Option 2:

psql postgres://[USERNAME]:[PASSWORD]@[HOSTNAME]:[PORT]/[DATABASENAME]?sslmode=require

If you are using the TigerData dashboard, this is how they look in the TigerData UI:

image

Congrats! Now you have connected via psql.

Related resources: psql + Postgres

  • Connect with psql
  • Data Processing With PostgreSQL Window Functions
  • PostgresSQL extensions
  • Manual PostgresSQL configuration and tuning
  • Integrate PostgreSQL with Tiger Cloud
  • A Guide to Scaling PostgreSQL

About TimescaleDB and PostgreSQL Queries

Now that you've installed psql, you are ready to start easily interacting with your PostgreSQL—or TimescaleDB—database.

TimescaleDB is built on PostgreSQL and expands its capabilities for time series, analytics, and events. It will make your queries faster via automatic partitioning, query planner enhancements, improved materialized views, columnar compression, and much more. Plus, you can scale PostgreSQL for cheap with our multi-tiered storage backend.

If you're running your PostgreSQL database on your own hardware, you can simply add the TimescaleDB extension. If you prefer to try TimescaleDB in AWS, create a free account on our platform today. It only takes a couple of seconds, no credit card required!

FAQs: How to Install psql on Mac, Ubuntu, Debian, Windows

Q: How do I check if psql is already installed on my system? A: You can verify if psql is already installed by opening your command line program and typing psql --version. If you've previously installed PostgreSQL or TimescaleDB, you likely already have psql installed, as it comes bundled with these installations.

Q: How do I install psql on macOS? A: To install psql on macOS, first install the Brew Package Manager, then run brew doctor, brew update, and brew install libpq commands in sequence. Finally, symlink psql into /usr/local/bin by running brew link --force libpq to make the psql command available system-wide.

Q: How do I install psql on Ubuntu or Debian? A: Installing psql on Ubuntu or Debian is straightforward using the apt package manager. Simply run sudo apt update followed by sudo apt install postgresql-client in your terminal. This installs only the psql client without the full PostgreSQL database server.

Q: What's the recommended way to install psql on Windows 10? A: For Windows 10, the recommended approach is to use the official installer from PostgreSQL.org. This installer provides a wizard-based setup that guides you through the installation process and includes psql along with other PostgreSQL tools.

Q: How do I connect to a PostgreSQL server using psql? A: To connect to a PostgreSQL server, you can use either the command format psql -h [HOSTNAME] -p [PORT] -U [USERNAME] -W -d [DATABASENAME]a (which will prompt for password) or the connection string format psql postgres://[USERNAME]:[PASSWORD]@[HOSTNAME]:[PORT]/[DATABASENAME]?sslmode=require. Both methods require your server's hostname, port, username, password, and database name.

Date updated

Jun 11, 2025

Posted by

Ajay Kulkarni

Ajay Kulkarni

Share

Subscribe to the TigerData Newsletter

By submitting you acknowledge TigerData's Privacy Policy.

Date updated

Jun 11, 2025

Posted by

Ajay Kulkarni

Ajay Kulkarni

Share

Subscribe to the TigerData Newsletter

By submitting you acknowledge TigerData's Privacy Policy.

Hi, we’re Timescale! We build a faster PostgreSQL for demanding workloads like time series, vector, events, and analytics data. Check us out.