Installing PostgreSQL on Mac OS X

Suggest edits

EDB provides MacOS installers for PostgreSQL on the EDB downloads page. These installers simplify setting up a system. Rather than use the EDB installer, you can also obtain a prebuilt installation package and instructions directly from the PostgreSQL downloads page.

For a detailed walk-through of the installation process on Mac OS, see this tutorial.

When the PostgreSQL installation finishes, you can optionally invoke the Stack Builder package manager. Stack Builder provides a graphical interface for downloading and installing applications, drivers, utilities, and their dependencies. See Using Stack Builder for more information.

Note

If you're using the graphical installation wizard to perform a system upgrade, the installer preserves the configuration options specified during the previous installation.

Command-line tools

After installing PostgreSQL, you can run command-line tools by referencing them in the bin directory under the installation path you specified during installation. For example, to run psql from the default installation directory, enter:

/Library/PostgreSQL/15/bin/psql -U postgres

For ease of use, you can add this directory to your PATH by adding a line to your ~/.bash_profile. If using zsh, add it instead to ~/.zshrc.

export PATH="/Library/PostgreSQL/15/bin/:$PATH"

This step is especially important if you plan to use scripts or other software that rely on PostgreSQL tools, such as Python's psycopg2. You can instead add this directory to the system path.

Several other options for installing PostgreSQL on MacOS offer varying levels of flexibility, version support, add-ons, and so on. You find more details on the PostgreSQL website.


Could this page be better? Report a problem or suggest an addition!