How to Install Postgresql on Mac OS X


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


Update 7/4/2015:

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

Gotcha: If you’re using, 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.