- Install postgres with homebrew.
brew install postgres
- Add
/usr/local/bin
to the head of your$PATH
to ensure the homebrew version of postgres is used.
Add this to your .bashrc
or .zshrc
depending on your preferred shell.
PATH=/usr/local/bin:$PATH
- Create a database for your system to use. Your current user will be the owner.
initdb /usr/local/var/postgres
If one already exists, remove it with rm -rf /usr/local/var/postgres
and try the command above again.
- Create a LaunchAgent to start postgres on boot.
Your postgres version below may be different. Adjust the path for your system.
cp /usr/local/Cellar/postgresql/9.2.2/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents
If you notice another postgres LaunchAgent in ~/Library/LaunchAgents/
you should remove it.
- Load the LaunchAgent via
launchctl
.
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
-
Restart your system to kickoff the LaunchAgent.
-
If you're a rubyist and have already installed the 'pg' gem, you will need to uninstall and reinstall the gem.
gem uninstall pg && gem install pg
I hope this helps!
Please comment or submit changes.