How to install PostgreSQL on Mac?
PostgreSQL Installation on Mac:
During this guide you will learn how to install PostgreSQL latest version on your mac step by step.
- Download the latest version (13.4) from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads for Mac OS X
- Start the installation setup, you will go through the following configuration settings before initiating installation.
For example you can choose “admin” as your password to keep it simple and rememberable.
- 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
Replace the username, “postgres”, with the one your choose during setup.
If during setup, you chose to use another port, e.g., port 5433, use the following command:
psql -U postgres -p 5433
When promoted for password, enter the password you specified during setup.
All Set, Ready to go:
Now your installation has been completed. You are ready to import or create databases and start querying.
Please thumbs up if it was helpful!