How to Install Postgresql on Mac OS X

12.20.2014

There are a couple of ways I normally install Postgresql on Mac OS X.

1. Homebrew

You will first have to install Hombrew.

$ brew update
$ brew doctor
$ brew install postgresql
$ initdb /usr/local/var/postgres -E utf8
$ gem install lunchy
$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/Cellar/postgresql/9.2.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
$ lunchy start postgres
$ createdb
$ psql -h localhost

2. Postgres.app

Postgres.app

Update 7/4/2015:

Remember to set your path, as per instructions on the Postgres.app homepage.

Gotcha: If you’re using Postgres.app, remember to add host: localhost to the database config for both development and test. Otherwise you will get a unix socket error!

This is now my preferred way to install postgresql on mac since there is less command line stuff involved.

Sources

http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/