postgres user, forgotten password

Lists: pgsql-admin
From: Zouari Fourat <fourat(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: postgres user, forgotten password
Date: 2005-02-22 14:07:45
Message-ID: 621eda8a05022206077a5506c5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

Hello,
i forgot the postgres user password, how to resolve this problem.
once i have my postgres user working, how to list all users on the server ?
thanks a bunch


From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Zouari Fourat <fourat(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: postgres user, forgotten password
Date: 2005-02-22 14:54:17
Message-ID: 20050222145417.GE22550@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

On Tue, Feb 22, 2005 at 15:07:45 +0100,
Zouari Fourat <fourat(at)gmail(dot)com> wrote:
> Hello,
> i forgot the postgres user password, how to resolve this problem.
> once i have my postgres user working, how to list all users on the server ?
> thanks a bunch

Edit pg_hba.conf to use trust or ident authentication for "postgres".
You probably want to make sure there is no external access to the database
while doing this.

SELECT usename FROM pg_user;


From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Zouari Fourat <fourat(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: postgres user, forgotten password
Date: 2005-02-22 15:46:46
Message-ID: 1109087206.30529.83.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

On Tue, 2005-02-22 at 08:07, Zouari Fourat wrote:
> Hello,
> i forgot the postgres user password, how to resolve this problem.
> once i have my postgres user working, how to list all users on the server ?
> thanks a bunch

First off, PostgreSQL stores passwords as md5 hashes (well, the last few
versions do anyway) so you won't be able to retrieve the password,
although a brute force md5 cracker might be able to eventually guess it
if it isn't too complex.

However, the standard way I use for getting back in is:

edit pg_hba.conf and set it to have an entry for local all all trust at
the top. restart postgresql. Log in as postgres (psql template1 -U
postgres) change the postgres password. Edit pg_hba.conf and get rid of
the trust line, restart postgres, psql template1 -U postgres to get back
in, and use select * from pg_shadow to see all the usernames.