installing postgresql 8.2 on Leopard with macports

postgresql! one of my favorite high performance open source db, of course i have it running on my mac. compiling postgresql with macports isn’t that hard, follow the step below will guide you through the installation;

first of all, make sure your macports is updated by running the command;

sudo port -v selfupdate
sudo port -v sync # some user prefer to run port sync, port selfupdate does the same thing.

installing postgresql, start it and create super user

sudo port -v install postgresql82-server # compile and install postgresql database from macports.

by default, macports will create postgresql database directory and initialize the db.

[ 149]$ ls -al /opt/local/var/db/postgresql82/
total 0
drwxr-xr-x 3 root admin 102B Nov 13 21:27 .
drwxr-xr-x 3 root admin 102B Nov 13 21:27 ..
drwx—— 16 postgres postgres 544B Mar 10 16:35 defaultdb

if the db directory is not created, follow the step below;

sudo mkdir -p /opt/local/var/db/postgresql82/defaultdb # make database directory
sudo chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb # assign postgre user and group
sudo su postgres -c ‘/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb’ # initialize default database

the default installation doesn’t include postgresql binary file into /opt/local/bin, add postgresql executable files into your shell environment

takizo@redarrows(~)
PATH=${PATH}:/opt/local/lib/postgresql82/bin

now, we will launch postgresql database and create super user and database

takizo@redarrows(~)

sudo /opt/local/etc/LaunchDaemons/org.macports.postgresql82-server/postgresql82-server.wrapper start
server starting # start postgresql database

sudo su – # switch to root user

sudo posrgres – # switch to postgres user

/opt/local/lib/postgresql82/bin/createuser -s -d -r -P

exit # quit as postgres user

exit # quit as root user

createdb -O takizo takizo # create database with takizo as privilege user

You are done, now you can logon to postgresql database with your username (mine is takizo)

psql82 -U takizo takizo

Since you have created super user, next time you can create new user with createuser command,

createuser -S -D -R -P -U takizo edward # create user edward with privilege account takizo
Enter password for new role: # password is hidden :p
Enter it again: # confirmed password is hidden too :)
CREATE ROLE # new user has been created

Happy playing with postgresql database!

Related posts:

  1. postgresql82-server compile error on Apple Leopard with Macports 1.5 I wasn’t able to compile postgresql82-server on my machine, it’s...
  2. Install MySQL5 Server on Apple Mac Leopard with MacPorts Previously I wrote a post on “installing postgresql 8.2 on...
  3. PostgreSQL Database signal 6 Error On Apple Mac After I have done PostgreSQL upgrade through MacPort, the database...
  4. How do I Start Application Services with launchctl When Apple Mac Leopard Boot Up If you have MySQL, PostgreSQL, Apache2 or other application installed...
  5. OS X Lion Macports OS X Lion Macports, Can I upgrade from Snow Leopard?...
  6. MySQL 5 Server Cannot Start on Apple Mac Leopard There were some problem during configuring MySQL5 Server on Leopard...
  7. Problem Upgrade Apache2 on MacPorts I was trying to upgrade apache2 on my Macports but...
  8. Install MySQL5 on Mac OSX With Darwin Port Before installing MySQL5, please be sure you have Darwin Port...
  9. Create Root Privilege User on MySQL By default, MySQL root privileges user is “root”, I always...
  10. Symfony, Unable to get sequence id with PostgreSQL Database When doing Symfony development, I usually build the database schema...

6 Responses to “installing postgresql 8.2 on Leopard with macports”

  1. ram Says:

    in the installing time what i write in the password box

  2. Install MySQL5 Server on Apple Mac Leopard with MacPorts | takizo, not takezo Says:

    [...] I wrote a post on “installing postgresql 8.2 on Leopard with macports“, seem like quite a no. of people also interested to know how to MySQL5 as server on Mac [...]

  3. Victor Says:

    Thanks for this posting, it saved my day (ehm… night). Especially the selfupdate of MacPorts at the beginning, I would have given up because it was some months old and it did not find any PgSQL sources anymore.

    I have a question on the first “createuser” call: is there something missing, the user name? Because at that point the postgres user should already exist…

    [...]
    > /opt/local/lib/postgresql82/bin/createuser -s -d -r -P [...here???...]
    > exit # quit as postgres user
    [...]

  4. Em Says:

    @Victor

    The postgres user does already exist in the OS at that point. The createuser command is for creating users (technically roles) within postgresql itself. After running the command it prompts for the name of the role if you do not specify it on the command line.

    Here is a URL for the full documentation of the command:
    http://www.postgresql.org/docs/8.3/static/app-createuser.html

  5. Victor Says:

    @Em
    Thanks for your reply.
    I think I understand now: the user (or role how it is called in PostgreSQL) named “takizo”, which is used two lines later, was created interactively during this step. That was the missing link for me.

  6. Al Brown Says:

    slight misspelling here, should be postgres, not portgres:

    sudo port -v install portgresql82-server

Leave a Reply