Getting running with Postgres (on OS-X)

So I spent the best part of a friday morning "yak shaving" - getting postgres to run on OS-X in a development friendly way. I consulted The Google - and found thousands of ways one could install postgresql for development. I think the core of my problem is that a lot of the guides want you to have a hardened production installation. 

So what I recommend (thanks to Simon Harris): 

Install homebrew ! 
brew install postgresql

(have a coffee)

After it is installed, it spits out instructions on how to start, you may miss that, so here it is repeated: 


If this is your first install, create a database with:

    initdb /usr/local/var/postgres


If this is your first install, automatically load on login with:

    cp /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist ~/Library/LaunchAgents

    launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist


If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:

    launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

    cp /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist ~/Library/LaunchAgents

    launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist


Or start manually with:

    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


If you want to install the postgres gem, including ARCHFLAGS is recommended:

    env ARCHFLAGS="-arch x86_64" gem install pg


Finally - this is all running as your current user - no super user, no postgres user. You can simply run: 


createdb yourdbname-here

dropdb etc... 

It will always use your current user - which is perfect for development. Much easier than trying to shoehorn in server grade configurations.