Saturday, January 18, 2014

PostgreSQL 9.3 setup after the initial Macports installation

I recently installed PostgreSQL 9.3 using MacPorts. I know some of you use HomeBrew but I still have enough things installed using MacPorts, that work and upgrade well, that I'm still in the MacPorts camp. MacPorts installed PostgreSQL OK, but getting the installation initialized and running took a few hours on a Saturday. Here is a shell script to summarize what finally worked for me.

In creating the script above, I started with hints from:

I also needed these hints on OS X postgres user creation:

sudo dscl . change /Users/postgres NFSHomeDirectory /opt/local/var/db/postgresql82 /opt/local/var/db/postgresql93

This did not work:

sudo dscl . change /Users/postgres RealName "\n PostgreSQL-82 Server" 'PostgreSQL-93 Server'
<main> attribute status: eDSAttributeNotFound
<dscl_cmd> DS Error: -14134 (eDSAttributeNotFound)

But this did work:

sudo dscl . -create /Users/postgres RealName "PostgreSQL Administrator"