Thursday, May 05, 2011

Installing Postgres on Snow Leopard

1) sudo port install postgresql83 postgresql83-server
2)

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'

3) sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist

4) sudo su postgres -c '/opt/local/lib/postgresql83/bin/postgres -D /opt/local/var/db/postgresql83/defaultdb'

5) sudo vi /etc/profile

6) Add : PATH="/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql83/bin:$PATH"

7) createuser --superuser your_macusername -U postgres

8) createdb my_database

9) sudo env ARCHFLAGS="-arch x86_64" gem install pg

10) database.yml
development:
adapter: postgresql
database: your_db
username: your_db_username

Installing pgAdmin

sudo port install pgAdmin3

Upon completion of installation, you can find the application in /Applications/MacPorts/pgAdmin3


Reference:
Installing PostgreSQL on Snow Leopard 10.6


Installing PostgreSQL on Leopard using MacPorts