Wednesday, February 20, 2008

Installing PostgreSQL on OS X using Fink

For a current project I am playing around with PostgreSQL.

Sidenote: I am very positively suprised about the documentation of PostgreSQL...

I chose to install PostgreSQL on my MacBook using Fink (I try to use Fink whenever possible, because I believe serious package management pays off in the long term).

However the installation did not run through as smoothly as possible...

Here are the necessary steps:

Step 0: Install Fink
Go to the Fink project and follow their installation instructions.

Step 1: Install PostgreSQL
Just type
sudo fink install postgresql82
into a terminal.

This takes a while and a lot of gibberish appears on your terminal...
In my case there was a warning at the end, telling something about not installing plpgsql. Since I am not planning to use PL/pgSQL, I just ignored that...

Step 2: Initialize the Database
According to the fink package description, this step should not be necessary. But in my case the installation process did not initialize the database, so I had to do it manually.

Type
sudo -u postgres initdb -D /sw/var/postgresql-8.2/data/
into a terminal.

Step 3: Start the dbms
Type
sudo pgsql.sh start
into a terminal.

This uses a script provided by fink. You could also start the dbms with the native command (i.e. pg_ctl, just look at the script...)

Step 4: Create a database
This is optional, you can do this also with pgAdmin (see below). But it is a good check, if the previous step worked.

Type
sudo -u postgres createdb testdb
into a terminal.

Step 5: Get pgAdmin and connect
PgAdmin is a client application to access postgres databases. You can get it here.

After starting pgAdmin you have to add the server (File->Add Server...):
Picture 2.png
To begin with connect as the user 'postgres' (which was created during the fink installation process), which has full administration privileges. Leave the password blank.

This should be it...

BTW: Fink installs the PostgreSQL documentation here:
/sw/share/doc/postgresql-8.2/html/index.html
Related Posts Plugin for WordPress, Blogger...