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

5 comments:

  1. Great article, thank you. This is exactly what I was looking for.

    I have installed PostgreSQL on my macbook but I didn't know how to run it.

    I have to run a few tests for my Jabber server with PostgreSQL so I started to search Internet for a guide to use PostgreSQL on the macbook. Thanks to you I didn't have to look too long.

    ReplyDelete
  2. Thanks a lot, now I have pg working on my MacBook :)

    ReplyDelete
  3. How to install PG and make it work with APache/PHP on OSX? I have XAMPP installed. Thanks for any help!

    ReplyDelete
  4. Hello, i've found this blog when i wae really getting confused how to install postgre on my mac.

    This is really helpful :)

    Thank you very much.

    ReplyDelete
  5. How can i uninstall it using fink?
    Fink remove does not seem to work.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...