Installing Postgres on MAC

For MAC:

  1. Install Homebrew
  2. brew install postgres
  3. initdb /usr/local/var/postgres
  4. /usr/local/Cellar/postgresql//bin/createuser -s postgres 

or 

/usr/local/opt/postgres/bin/createuser -s postgres 

 which will just use the latest version. 

5. start postgres server manually:

 pg_ctl -D /usr/local/var/postgres start

To start server at startup

  • mkdir -p ~/Library/LaunchAgents
  • ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
  • launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Now, it is set up, login using 

psql -U postgres -h localhost 

or use PgAdmin for GUI.

By default user postgres will not have any login password.