Setting up Postgres from DarwinPorts on MacOS X 10.4 (intel)

Yes, google, this is for you. Or more precisely, for me – when I forget what I did later…

* create a new user on the local machine named “postgres” (Marc Liyanage’s Postgres package site has a nice little postgres tiff icon for the user too)

* pick and make a directory where the data is going to live : mkdir /opt/local/var/postgres/

* set the ownership to the new postgres user id : sudo chown postgres /opt/local/var/postgres/

* in ther terminal window, switch to the postgres user : su -l postgres

* initialize the databases : /opt/local/lib/pgsql8/bin/initdb -D /opt/local/var/postgres

* make a log directory : mkdir /opt/local/var/pglog

* set it’s ownership : sudo chown postgres /opt/local/var/pglog

* fire up the database : su – postgres -c ‘/opt/local/lib/pgsql8/bin/pg_ctl -D /opt/local/var/postgres -l /opt/local/var/pglog/postgreslog start’ (this bit actually went into a StartupItems launcher that I borrowed from Marc’s postgres site and edited)

Now for the databases:

* su – postgres

* /opt/local/lib/pgsql8/bin/psql

* create database mydb

* create user myuser with password ‘foo’

And verify I can get in there:

* /opt/local/lib/pgsql8/bin/psql myuser mydb

There’s some handy (although slightly different paths) documentation on Apple’s site about setting up and using Postgres as well. Tweak the paths and you should be all good.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s