Saturday, May 31, 2014

Setting up a Postgres database

First you create the directory the database resides in:
sudo mkdir /Volumes/Data/Postgresql/perfido
Then you make sure that it's owned by the user postgres
sudo chown -R postgres:postgres /Volumes/Data/Postgresql
and finally you create the database
sudo su postgres -c "initdb -D /Volumes/Data/Postgresql/perfido"
and you're ready to go.

If things don't work (you get a "could not connect to server" message) it's very likely a path issue (see this), and therefore fix your path:

export PATH=/opt/local/lib/postgresql93/bin:$PATH

To start postgres automatically use:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql93-server.plist

Change to "unload" to stop the system from starting postgres automatically.