Wednesday, February 06, 2008

Setting Up Postgresql

Was mucking around with postgresql again, given that I've decided to start everything at right footing, rather than to stick with mysql, which is what I'm more used to, for various reasons I've remembered from my database lectures in the past.

Installation's a little bit different from mysql, but with a bit of Googling, there are some pretty good instructions out there that makes things clearer. Subsequently after installation, there may be two error messages to take note of, which you may encounter after the install process:
psql: FATAL:  user "vincent" does not exist
If you're not running as user 'postgres', this error indicates that the user (in my case 'vincent') does not exist in the database. Upon installation, postgres only allow the user 'postgres' to access the database by default, so it's necessary have the right user profile to make configuration changes. This is done by invoking 'su' (or 'sudo' for some users) into 'postgres' and invoke the 'createuser' command:
% createuser
Enter name of user to add: vincent
Shall the new user be allowed to create databases? (y/n) y
Shall the new user be allowed to create more new users? (y/n) y
The rights allow users to create databases, and to add new users to the database, which on a standalone machine that I have, it's probably ok to have 'y' for both.

You're not done with the process yet if you haven't created your database for access, and if you executed 'psql' again, the following error props up:
psql: FATAL:  database "vincent" does not exist
This is relatively easy to fix. Since you've already have database creation access, just by issuing 'createdb' will initialize your database for use.
% createdb
Time to start creating and populating tables from here!


Post a Comment