How to install Postgresql Client using Homebrew

How to install Postgresql Client using Homebrew

July 26, 2023

Psql is a command-line interface for interacting with PostgreSQL, a powerful and open source relational database system. Brew is a package manager for macOS that makes it easy to install and manage software. Here are the steps to install psql with brew:

  • First, install the brew package manager if you don’t have it already. You can do this by running the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Second, update brew by running the following commands:
brew doctor
brew update
  • Third, install libpq by running the command:
brew install libpq

Libpq is a library that contains psql and other PostgreSQL client utilities.

  • Fourth, symlink psql (and other libpq tools) into /usr/local/bin by running the command:
brew link --force libpq

This will make psql accessible from any directory in your terminal.

  • Fifth, check the version of PostgreSQL using the psql command:
psql --version

You should see something like this:

psql (PostgreSQL) 13.4

Congratulations, you have successfully installed psql with brew! You can now use psql to connect to PostgreSQL databases and run SQL queries.