Making Postgresql82 run under leopard (from Mac Ports)
After installing the Mac Ports postgresql82-server port, I tried to make it run. It didn’t. The problem was that su didn’t like running anything as user postgres. Here’s the original instructions:
########################################################### # A startup item has been generated that will aid in # starting postgresql82-server with launchd. It is disabled # by default. Execute the following command to start it, # and to cause it to launch at startup: # # sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql82-server.plist ########################################################### ---> Installing postgresql82-server 8.2.6_0 To create a database instance, after install do sudo mkdir -p /opt/local/var/db/postgresql82/defaultdb sudo chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb'And here’s my test to determine if su was working:
sudo su postgres -c idI got no output… So I tried
sudo -u postgres idAnd I get:
uid=401(postgres) gid=401(postgres) groups=401(postgres)So now what?
There’s an easy way to deal with this: Grab the server admin tools from Apple and install them.
Next, fire up Workgroup Manager (its in your /Applications/Server folder). Ignore the dialog and go straight to the menu and select Server -> View Directories. Select the PostgreSQL Server user in the left-hand pane, then select the Advanced tab and change the Login Shell to something like /bin/sh. See the picture for details. Don’t forget to hit Save.

Now the command from before works:
# sudo su postgres -c id uid=401(postgres) gid=401(postgres) groups=401(postgres)So now we can finish the last step to initialize the database, then fire up Postgres.
sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb'
If you already ran the launchctl command, you can make Postgres start with these two commands:
sudo launchctl unload -w /Library/LaunchDaemons/org.macports.postgresql82-server.plist sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql82-server.plist
Otherwise just run the load version of the command.
Trackbacks
Use the following link to trackback from your own site:
http://blog.royhooper.ca/trackbacks?article_id=70
