Reset lost PostgreSQL admin password
Problem
The PostgreSQL admin/superuser account password is lost.
Solution
If the PostgreSQL admin/superuser account password is lost follow this procedure to reset it.
- Create a copy of pg_hba.conf so you can revert to it later
- Open pg_hba.conf
- Change "md5" to "trust" everywhere
- Go to the command line (cmd.exe)
- CD into the PostgreSQL bin directory (ex: C:\Program Files\PostgresSQL\9.0\bin)
- Enter: psql -U postgres ForayAdams
- (NOTE: if the admin account isn't postgres user whatever the admin account is named; likewise for the db being ForayAdams)
- Enter: ALTER USER postgres WITH ENCRYPTED PASSWORD 'somestrongpassword';
- (NOTE: again, change postgres if necessary)
- Enter: \q
- Start PgAdmin III and enter the password just set to make sure it works.
- Swap the pg_hba.conf back to the previous version.
Related articles
© 2023 Foray, LLC - All Rights Reserved