How to install PostgreSQL on Mac?

  • Environment Variables:
    You have to set the environment variables based on the version you have installed, e.g., I have just installed version 13 as shown in the installation summary above.
    Note: If you are installing a different version of PostgreSQL, you need to replace the number “13” in the paths with your installed version number.
export PATH=/Library/PostgreSQL/13/bin:$PATH 
export PGDATA=/Library/PostgreSQL/13/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/Library/PostgreSQL/13/share/locale
export MANPATH=$MANPATH:/Library/PostgreSQL/13/share/man

Start PostgreSQL (command line)

Enter the following into your command line tool

psql -U postgres
psql -U postgres -p 5433

All Set, Ready to go:

Now your installation has been completed. You are ready to import or create databases and start querying.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kashif Rabbani

Kashif Rabbani

I am a data science PhD researcher who loves to write!