Friday, July 29, 2011

Change postgresql password on Ubuntu


How to change postgresql password on Ubuntu

 
I’m using Postgresql-8.3  on Ubuntu 9.04.

Initially , take pg_hba.conf from /etc/postgresql/8.3/main/
In that you will find an entry like this,
host    all         all         172.16..0/24        md5

Change it to
host    all         all         172.16..0/24        trust

Then restart the postgresql database..
if it is ubuntu use the command /etc/init.d/postgresql restart 

Now issue the command
sudo psql -h -d -U postgres
(it should not ask for postgresql password..). 

It will ask for your unix password
Then give the command
alter user postgres with password 'new password'
to change the password..
Thats it..