Wednesday, November 5, 2008

Using pgAdmin III to set-up PostgreSQL default access

This tutorial is for those who want to use pgAdmin III in setting-up postgreSQL default access inside an Ubuntu 8.10. If you have not done so, install postgresql by typing in the terminal the following:

sudo apt-get install postgreql

then to install pgadmin III

sudo apt-get install pgadmin3


1. Changing postgres password.

The default authentication to the database is md5, in simplest term the database will require password for user authentication (see postgreSQL documentation for the meaning of md5 authentication). And the default user is postgres. Initially, we don't know the password of the user postgres and it is the only user defined within the database. To set up the password, do the following (steps a-d assumes you are working on a terminal):

a. cd /etc/postgresql/8.3/main
b. sudo vim pg_hba.conf #or any text editor you like
c. #inside the file change md5 --> trust
#the trust option allows any user (as long as it is in the database)
#to login without any password.
#then save your work

d. sudo /etc/init.d/postgresql-8.3 restart #this is necessary for the changes to take place
e. #start pgadmin3
f. #create a new connection

g. #login as postgres



#postgre can now login without the need for a password
h. #modify the postgres password by expanding the login roles, and by double-clicking
#the postgre icon. in the dialogue box, type the desired postgres password, then click ok.


And that's it, the password for the user postgre have changed.


2. Protecting the database.

To change, the original postgresql authentication setting. We have to do the following.

a. Close pgadminIII if it is still running.
b. Repeat steps a - d, only this time replace trust --> md5.


The next time you access the database, it will now be your password the system will be accepting.

Fin

No comments: