To install Postgres.app, just drag it to your Applications folder and double click.
You can also start Postgres.app from other locations, but some features may not work.
To use command line tools (like psql
) from your Terminal, add Postgres.app’s bin folder to your $PATH
:
You can do this with the following command:
sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
For more details, see the section on Command Line Tools.
By default, Postgres.app configures a server (cluster) with the latest supported version of PostgreSQL. All you need to do is click the “Initialize” button.
A PostgreSQL server (cluster) can have multiple databases.
By default, Postgres.app creates a database with the same name as your user name.
You can create more databases using the createdb
command line tool, or using the CREATE DATABASE
SQL command.
Postgres.app allows running multiple PostgreSQL servers (clusters) on your Mac. This is especially useful if you want to run multiple versions of PostgreSQL simultaneously.
To add a cluster, click the “+” icon in the sidebar.
The default settings for PostgreSQL allow any app on your computer to connect without a password (“trust” authentication).
To improve security, we recommend protecting all PostgreSQL servers with a password by enabling “scram-sha-256” authentication.
trust
with scram-sha-256
(On PostgreSQL servers before version 14, use md5
instead of scram-sha-256
.)
After setting a password, the databases will no longer be shown in Postgres.app.
By default, PostgreSQL only allows connections from apps on your computer. Follow these instructions to allow other computers on your network to connect.
listen_addresses
setting, remove the leading #
, and change the value from 'localhost'
to '*'
.host all all 0.0.0.0/0 scram-sha-256
(allow secure authentication with a password for all databases and all users from all IPv4 addresses)Postgres.app includes a number of useful extensions.
Before you can use them, you need to install them in each database using the CREATE EXTENSION
SQL command.
Postgres.app includes the following extensions:
For the full list, execute the SQL query select * from pg_available_extensions;
It is also possible to build custom PostgreSQL extensions for Postgres.app.
Typically, you just need to make sure the $PATH is configured correctly and that pg_config
works, then you can build most extensions with make && make install
.
The first time you do this, macOS will show that “Terminal tried to modify an application”. This setting can be changed in System settings / Security.
However, this is an advanced topic and requires some familiarity with Unix build systems.
Installing custom extensions will break the code signature of Postgres.app. Currently, macOS verifies the code signature only the first time you launch an application, so as long as you launch Postgres.app before building custom extensions it should work. However, this may change in a future version of macOS.
Custom extensions will be removed when updating Postgres.app, so build them again afterwards.
/Applications/Postgres.app/Contents/Versions/latest/bin
/Applications/Postgres.app/Contents/Versions/latest/include
/Applications/Postgres.app/Contents/Versions/latest/lib
~/Library/Application Support/Postgres/var-XX
(XX is the major version of PostgreSQL)~/Library/Application Support/Postgres
)defaults delete com.postgresapp.Postgres2
$PATH
config for the command line tools:sudo rm /etc/paths.d/postgresapp