Postgres Housekeeping
Posted by Shady Mon, 29 Jan 2007 15:39:29 GMT
Previously, we installed postgresql on our OS X computers. Now lets do a little bit of house keeping and clean up to make it more convenient for general use.
We'll start with the easiest problem first - getting rid of that postgres user hanging around our login window. One simple command takes care of this:
- sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add postgres
Next task is to get postgres to start up on its own. For this, we will use the newfangled technology provided by apple in 10.4: Launchd. Fortunatley, lots of smart (and not lazy) people have done the hard work for us. You can download a functional launchd item here
Note that the fine gentleman who made this Launchd item has his own tutorial for setting up postrgres. Check if out, if you like. There is a lot more detail to be had there, such as setting up perl and java to connect to postgres. However, his installation direction for postgres different then the one we used previously. As a result this we will need to change a few properties of this plist. An aside: since launchd items are just plists (xml files) we can use the plist editor that comes bundled with xcode tools to edit the file. And this works. A nice alternative, however, is the nifty little tool Launchd Editor, available here. Back to the action: we need to change the following properties of the plist file:
- The value for -D should be /usr/local/pgsql/data (or where ever you set your data directory)
- The value for log_directory should be /usr/local/pgsql/logs (or, again, where ever you set your logs directory).
- sudo cp org.postgresql.postmaster.plist /Library/LaunchDaemons
- sudo launchctl load /Library/LaunchDaemons/org.postgresql.postmaster.plist
- sudo launchctl start org.postgresql.postmaster
And there we are. We can nicely start and stop postgres, the user is gone from our window, and all is right with the world. If only we had some kind of GUI management tool for dealing with postgres . . . something like, oh, I dunno . . . .this, maybe?. Of course, if you're more partial to web based management solutions a la phpmysql, there is always phpPgAdmin.
Of course, we still only have on user set up . . . we have to use postgres to log in to our database. While I won't tell you exactly what you need to do in order to set up a new user, I will give you a hint: check the excellent postgres documentation for create role. With the documentation on that, and the GUI editing tool of your choice (or good ol' psql) you should have extra users up and running in no time. The LOGIN attribtue might help too.
Tune in next time, when we (finally!) get around to installing PostGIS.

Comments
Leave a response