There are a number of ways to install Postgres on Mac, here’s three. While these instructions are for a clean install of Lion, they may work for Mountain Lion.
The easy option! Simply go to Postgresapp.com download, and double click – that’s it! It also includes PLV8 and PostGIS (see second comment below for details). If you want more info about the project, check out this
Postgres one click installer
Another easy option! This is a one click installer from The EnterpriseDB PostgreSQL Company. It includes PostgreSQL, pgAdmin, PL/Java and the PL/pgSQL debugger plugin. Note that this creates a new postgresql user on your system – you may or may not like that
To install, simply download and double click, from here.
Homebrew – the much loved “missing package manager for OS X”.
brew install postgresql
Then follow the instructions at the end, for me there were:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.1.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
And these are handy to note
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
And stop with:
pg_ctl -D /usr/local/var/postgres stop -s -m fast
Which one to use?
If you want a quick an easy solution, the Postgresapp seems like a good choice – it just works. If you don’t mind a new user being created on your system them it might be worth trying the one click installer. If you already use Homebrew then that may be your preferred choice.
Personally I would go with the first or last choice as I’m not keen on having additional users on my system.
Install the pg gem
If you want to install the postgres gem, including ARCHFLAGS is recommended:
env ARCHFLAGS=”-arch x86_64″ gem install pg