The ramblings of Chad Humphries

Posts Tagged ‘macports

Going out with that other database…

After growing tired of mysqls fast and loose approach I thought let’s try PostgreSQL. Here is the tale of my journey on OSX.

A lot of the instructions are gotten from Robby on Rails.

1. Get MacPorts

2. Install PostgreSQL

sudo port install postgresql81
--->  Fetching postgresql81
--->  Attempting to fetch postgresql-base-8.1.5.tar.bz2 from ....
--->  Verifying checksum(s) for postgresql81
--->  Extracting postgresql81
--->  Configuring postgresql81
--->  Building postgresql81
--->  Staging postgresql81 into destroot
--->  Packaging tgz archive for postgresql81 8.1.5_0+darwin_8
--->  Installing postgresql81 8.1.5_0+darwin_8

3. Add the new postgres location to your path. You could put it in your local profile or /etc/profile.


4. Install postgres gem:

sudo gem install postgres --  --with-pgsql-include-dir=/opt/local/include/postgresql81 --with-pgsql-lib=/opt/local/lib/postgresql81/

5. Finally, manually finish up (Anyone know why the gem doesn’t properly finish?) Switch to the gem directory on your install and run.

sudo make install

6. Working with postgres (taken from the Argon walk-through).

  • Open up iterm and go to your home directory
  • Init your new PostgreSQL database with: initdb -D pgdata
  • Start up PostgreSQL with: pg_ctl -D pgdata -l pgdata/psql.log start
  • Create a new database with: createdb yournewdb_dev
  • Test the new database with: psql yournewdb_dev

7. Change your database.yml

    adapter: postgresql
    database: yournewdb_dev

    adapter: postgresql 
    database: yournewdb_test

    adapter: postgresql
    database: yournewdb_production

And there you go. Hopefully my journey with postgres will be fun filled 😉


Written by spicycode

December 3, 2006 at 6:33 pm

Posted in osx

Tagged with ,