Password recovery in Postgresql
I forgot the password for the user postgre.
I googled about how to recover the password.
Step 1. Login without password
# vim /var/lib/pgsql/data/pg_hba.conf
Change
local all postgres password|indent|md5
to
local all postgres trust
Restart postgres
# /etc/init.d/postgresql-8.4 restart
Step 2. Change password
# psql -U postgres template1 -c "ALTER USER postgres PASSWORD 'secret'"
Step 3. Revert back the original settings
# vim /var/lib/pgsql/data/pg_hba.conf
Change
local all postgres trust
to
local all postgres password|indent|md5
Restart postgres
# /etc/init.d/postgresql-8.4 restart
May 9th, 2011