Setting Up Postgres on Mac OSX with Homebrew
I ran into some challenges installing postgres via homebrew. I attempted to follow these instruction, as is advised by the postgres website but ran into further problems. The following steps outline how I was able to finally work around the problems. Note that I'm using Mac OSX 10.6.8.
Uninstall old versions of postgres:
| 1 | brew rm postgresql --force | 
Update homebrew:
| 1 | brew update | 
Install postgres:
| 1 | brew install postgresql | 
Make a postgres directory:
| 1 | sudo mkdir -p /usr/local/var/postgres | 
Tweak its permissions (change "YOURUSERNAME" to your username:
| 1 | sudo chown YOURUSERNAME:admin /usr/local/var/postgres/ | 
initdb:
| 1 | initdb /usr/local/var/postgres/data | 
Add postgres to LaunchAgents directory:
| 1 | cp /usr/local/Cellar/postgresql/9.2.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents | 
Load it:
| 1 | launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgres.plist | 
Start the server:
| 1 | pg_ctl -D /usr/local/var/postgres/data -l /usr/local/var/postgres/data/server.log start | 
Note: If you receive a 'FATAL:  role "postgres" does not exist' message when doing something like rake db:create, you may be missing the default postres user, postgres. This can be fixed with the following command:
| 1 | createuser -s -U $USER |