Skip to content

Instantly share code, notes, and snippets.

@bostonaholic
Last active December 10, 2015 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bostonaholic/4454413 to your computer and use it in GitHub Desktop.
Save bostonaholic/4454413 to your computer and use it in GitHub Desktop.
Tips for install Postgres on OS X

Tips for installing Postgres on OS X

  1. Install postgres with homebrew.

brew install postgres

  1. 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

  1. 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.

  1. 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.

  1. Load the LaunchAgent via launchctl.

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

  1. Restart your system to kickoff the LaunchAgent.

  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment