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.

Published by heckj

Joe has broad software engineering development and management experience, from startups to large companies. Joe works on projects ranging from mobile to multi-cloud distributed systems, has set up and led engineering teams and processes, as well as managing and running services. Joe also contributes and collaborates with a wide variety of open source projects, and writes online at https://rhonabwy.com/.

%d bloggers like this: