Re: Lost password to user postgres

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Philippe Salama <karebacnyc(at)yahoo(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Lost password to user postgres
Date: 2006-12-02 23:25:23
Message-ID: 1165101923.25316.8.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Sat, 2006-12-02 at 11:44 -0800, Philippe Salama wrote:
> 2 years ago, I installed postgresql on my desktop and used it for a
> while for learning purposes. Then, I stopped using it. I forgot the
> password to the user postgres

You don't have to reinstall. you've got three basic options:

1. Change the password in single user mode
2. Edit pg_hba.conf and set it to trust mode, change your password,
change back to md5
3. Re-initdb your cluster.

For 1:
su - postgres (from root if you have to)
pg_ctl stop
postgres template1 (or some other database you know exists)
alter user postgres password 'newpassword';

For 2:
su - postgres
cd $PGDATA
vi pg_hba.conf
// change entries at bottom to trust
pg_ctl reload
psql template1
alter user postgres password 'newpassword';

For 3:
su - postgres
pg_ctl stop
echo $PGDATA // make sure this is set to something like /var/lib/pgsql
rm -rf $PGDATA/*
initdb // with whatever options you need.

I prefer option 2, as you don't have to take down your database to do
it.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Marlowe 2006-12-03 02:14:47 Re: Settings for writing!
Previous Message Philippe Salama 2006-12-02 19:44:38 Lost password to user postgres