How to install postgres 8 on Mac OS X
By Justin Silverton
step 1: install the fink project, available Here
from the fink website: "The Fink project wants to bring the full world of Unix Open Source software to Darwin and Mac OS X. We modify Unix software so that it compiles and runs on Mac OS X ("port" it) and make it available for download as a coherent distribution. Fink uses Debian tools like dpkg and apt-get to provide powerful binary package management. You can choose whether you want to download precompiled binary packages or build everything from source"
Step 2: (install readline) (within a terminal) sudo /sw/bin/fink install readline
Step 3: give yourself root access with sudo and download the latest version of postgres with curl
note: this can be extracted into any directory, I just chose to use /usr/local/postgres_src
curl -O ftp://ftp.us.postgresql.org/pub/PostgreSQL/source/v8.1.3/postgresql-8.1.3.tar.gz
tar -xzvf postgresql-8.1.3.tar.gz
Step 4: make and configure postgres 8
(within the postgres-8.1.3 directory)
./configure --with-includes=/sw/include/ --with-libraries=/sw/lib
Step 5: add a new user that will have permissions on the database.
This can be done by going into System->Preferences->Accounts and "New User". Call this new user "postgres".
Step 6: Create postgres data directories and change the ownership to the postgre user that was created in step 5.
chown postgres /usr/local/pgsql/data
Login to the postgres user account
su -l postgres
Step 7: initialize the database
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
Step 8: start the server
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
Step 9: start creating tables
Step 10: start executing commands on the newly created table. Postgres is now installed.
psql test (psql is a command-line utility for executing sql commands)
create table newtable (name varchar, email varchar);
insert into newtable (name,address) values ('John','firstname.lastname@example.org');