How to install Postgres.app to use PostgreSQL database on Mac

How to install Postgres.app to use PostgreSQL database on Mac

How to Mac

Share

In this tutorial we will learn to install Postgres.app to use PostgreSQL database on Mac.

What is Postgres.app?

Postgres.app is a full-featured PostgreSQL installation packaged as a standard Mac app. -- https://postgresapp.com

Download

Visit postgresapp.com and download the software on your Mac.

Run the installer and move the Postgres.app into the Applications directory.

Default settings

Postgres.app will install on your Mac with the following default settings.

Host localhost
Port 5432
User your system user name
Database same as user
Password none
Connection URL postgresql://localhost

Starting Postgres.app

Open the Postgres.app and you will see the following.


mac postgres.app

To start the server and list out the database click on the Start button. You will now see your databases.


mac postgres.app start

In the above image you can see the database that is there on my Mac.

Connect to a database using psql

To connect to a database using psql just double click on the database.

In the following example I have double clicked on yusufshakeel database and I get to see the following in the terminal.


mac postgres.app psql terminal

Listing all databases

To list all the databases in the terminal we can use the \l command like the following.

yusufshakeel=# \l
                                     List of databases
     Name     |    Owner     | Encoding |   Collate   |    Ctype    |   Access privileges   
--------------+--------------+----------+-------------+-------------+-----------------------
 postgres     | postgres     | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0    | postgres     | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
              |              |          |             |             | postgres=CTc/postgres
 template1    | postgres     | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
              |              |          |             |             | postgres=CTc/postgres
 yusufshakeel | yusufshakeel | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(4 rows)

Switching between databases

To switch or connect to a new database in our PostgreSQL local server we can use the \c command followed by the database name.

In the following example I am connecting from yusufshakeel database to postgres database.

yusufshakeel=# \c postgres;
You are now connected to database "postgres" as user "yusufshakeel".

Stopping Postgres.app

When you are done with your work and want to stop the PostgreSQL server then click on the Stop button.

Alright, this brings us to the end of this tutorial. Please share this tutorial if you find it interesting and helpful. Thanks for reading. Have fun developing.

Share