Thursday, June 29, 2006

Postgres setup

Installing Postgres isn't a problem using apt-get but setting up the first user and database had me foxed for a while.

First create a postgres user and database with your username. When using psql, you will open a database with your username as default, so its easier to create the table with your username at the start.
~$ sudo su postgres -c createuser yourusername
~$ sudo su postgres -c createdb yourusername
Now connect to your postgres database and alter the password the user that has just been created.
~$ sudo su postgres -c psql yourusername
=# ALTER USER yourusername WITH PASSWORD 'yourpassword';
=# \q
Don't forget the terminating ; in the SQL call. I found these helpful hints in the postgres manual for version 8.0:
http://www.postgresql.org/docs/8.0/interactive/user-manag.html

No comments: