Skip to content

Setup PostgreSQL on Mac OS X

MySQL was feeling lonely, so I decided to install PostgreSQL as well:

sudo port install postgresql83 postgresql83-server

Now update your path by adding this line to your .profile:

export PATH=”/opt/local/lib/postgresql83/bin:$PATH”

# the exact order is up to you

I also recommend adding the architecture flag if you use an Intel-based Mac:

export ARCHFLAGS=”-arch i386″

# Don’t forget to restart your terminal or resource .profile

Install the postgres rubygem:

sudo gem install postgres

Create the default database:

sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb

sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb

sudo su postgres -c ‘/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb’

To start the server:

sudo su postgres -c ‘/opt/local/lib/postgresql83/bin/postgres -D /opt/local/var/db/postgresql83/defaultdb’

To start the server with a logfile (warning this does not work for me):

sudo su postgres -c ‘/opt/local/lib/postgresql83/bin/pg_ctl -D /opt/local/var/db/postgresql83/defaultdb -l logfile start’

This post was partly inspired by the March 2008 article by ShiftEleven.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*