Snow Leopard Development Server: PostgreSQL
The first MacPort to be installed will be PostgreSQL. The latest version available is PostgreSQL 8.4, and installation involves both MacPorts work and some command line activity.
PostgreSQL Install
Like many MacPorts installations, there is some followup work to do once a package is installed. For PostgreSQL, that means ensuring that postgres owns the database directory and then initializing that database.
sudo port -d selfupdate sudo port install postgresql84 sudo port install postgresql84-server sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb'
Like the general MacPorts installation, the path to PostgreSQL command-line tools is not known to the system, so I append /opt/local/lib/postgresql84/bin
in /etc/paths
.
sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist
To manually start PostgreSQL
sudo su postgres -c '/opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/defaultdb'
Restoring a PostgreSQL Database
Prior to rebulding my development server, all the databases were dumped from the PostgreSQL database. With a fresh install of PostgreSQL 8.4, I must first create a user and then create and restore individual databases.
createuser -U postgres -P bignerd createdb -U postgres --encoding UNICODE --template template0 bnr pg_restore -U markf -d bnr bnr.dump
PosgtreSQL is now up and running, and the Big Nerd Ranch database is restored and ready.