TigerData logo
TigerData logo
  • Product

    Tiger Cloud

    Robust elastic cloud platform for startups and enterprises

    Agentic Postgres

    Postgres for Agents

    TimescaleDB

    Postgres for time-series, real-time analytics and events

  • Docs
  • Pricing

    Pricing

    Enterprise Tier

  • Developer Hub

    Changelog

    Benchmarks

    Blog

    Community

    Customer Stories

    Events

    Support

    Integrations

    Launch Hub

  • Company

    Contact us

    About

    Timescale

    Partners

    Security

    Careers

Log InTry for free
TigerData logo

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 Tiger Data Newsletter

By submitting, you acknowledge Tiger Data's Privacy Policy

2026 (c) Timescale, Inc., d/b/a Tiger Data. All rights reserved.

Privacy preferences
LegalPrivacySitemap

Copy as HTML

Open in ChatGPT

Open in Claude

Open in v0

Ajay Kulkarni

By Ajay Kulkarni

4 min read

Aug 22, 2019

TutorialsPostgreSQL#CTA-homepage#Callout-technical

Table of contents

01 Before You Start02 Install on MacOS Using Homebrew03 Install on Ubuntu 23.10,22.04 and Debian 1204 Install Windows 1005 Last Step: Connect to Your PostgreSQL Server06 Related resources: psql + Postgres07 About TimescaleDB and PostgreSQL Queries08 FAQs: How to Install psql on Mac, Ubuntu, Debian, Windows

PostgreSQL for time series and events

Engineered for powerful price-performance and speed.

Learn more about Tiger Data

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

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

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

By Ajay Kulkarni

4 min read

Aug 22, 2019

Table of contents

01 Before You Start02 Install on MacOS Using Homebrew03 Install on Ubuntu 23.10,22.04 and Debian 1204 Install Windows 1005 Last Step: Connect to Your PostgreSQL Server06 Related resources: psql + Postgres07 About TimescaleDB and PostgreSQL Queries08 FAQs: How to Install psql on Mac, Ubuntu, Debian, Windows

Copy as HTML

Open in ChatGPT

Open in Claude

Open in v0

PostgreSQL for time series and events

Engineered for powerful price-performance and speed.

Learn more about Tiger Data

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 Tiger Data dashboard, this is how they look in the Tiger Data 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.


About the author

Ajay Kulkarni

By Ajay Kulkarni

Related posts

How to Automate Data Classification in PostgreSQL With OpenAI

How to Automate Data Classification in PostgreSQL With OpenAI

AI#Callout-pgaivector

Nov 22, 2024

Data classification is a crucial but challenging task. Learn how to automate it in PostgreSQL using open-source extensions (pgvector; pgai) and OpenAI models.

Read more

Combining Semantic Search and Full-Text Search in PostgreSQL (With Cohere, Pgvector, and Pgai)

Combining Semantic Search and Full-Text Search in PostgreSQL (With Cohere, Pgvector, and Pgai)

AI#Callout-pgaivector

Nov 15, 2024

Read how you can implement hybrid search in PostgreSQL by combining semantic and full-text search using Cohere, pgvector, and pgai.

Read more

Stay updated with new posts and releases.

Receive the latest technical articles and release notes in your inbox.

Share

Get Started Free with Tiger CLI