This is a pretty simple process, but one that I thought I would document because I ran into a few gotchas along the way.
I originally installed OS X using the one click installer from EnterpriseDB. Unfortunately, the installer hung while attempting to finish the installation process and they only thing to do was to roll back the install. I attempted to build from macports, but that proved to be a huge pain in my ass and reminded me a little bit too much of using Linux, so I scrapped that idea as well. I started browsing the EnterpriseDB installation notes and came across an unattended install. Since my installation failed trying to launch the final interactive stage of the installation, I said to myself “Self, I bet we should try this.”
- Download PostgreSQL from EnterpriseDB http://www.enterprisedb.com/products/pgdownload.do#osx
- Mount the OS X disk image file
- In the Terminal, change to the directory where the image file was mounted:
cd /Volumes/PostgreSQL\ 8.4.2-1/
- Start the unattended installation
- Once the installation has finished, add the following line to your .profile:
If you’ve never created your .profile you can do the following in a terminal window:
This will create the file if it doesn’t exist and will only change the last modification date if it does.
open /Applications/TextEdit.app .profile
This opens your .profile in the TextEdit application
- Save and close your .profile
- Create a new database user.
createuser [YOUR NAME HERE] --pwprompt --username=postgres
- When you’re prompted for the “Password:”, use “postgres”. This is the default password for the postgres superuser. Because you’ve just created another superuser, you’ll never have to touch this account again, but you should probably look up some fantastic documentation and learn how to change the password.
There you have it: how to set up and install PostgreSQL on OS X. If you want to continue forward and install a Ruby library to interact with PostgreSQL, just type
sudo gem install postgres-pr to install the pure Ruby version PostgreSQL driver. If you want to install one of the C-based drivers, you’ll need to mess around with macports.
Note: EnterpriseDB make and distribute a binary version of PostgreSQL for a variety of platforms. In addition, they provide paid support and also offer a variety of enterprise features. They have in no way paid me for this post.