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.

  1. Create a copy of pg_hba.conf so you can revert to it later
  2. Open pg_hba.conf
  3. Change "md5" to "trust" everywhere
  4. Go to the command line (cmd.exe)
  5. CD into the PostgreSQL bin directory (ex: C:\Program Files\PostgresSQL\9.0\bin)
  6. Enter: psql -U postgres ForayAdams 
    1. (NOTE: if the admin account isn't postgres user whatever the admin account is named; likewise for the db being ForayAdams)
  7. Enter: ALTER USER postgres WITH ENCRYPTED PASSWORD 'somestrongpassword';
    1. (NOTE: again, change postgres if necessary)
  8.  Enter: \q
  9. Start PgAdmin III and enter the password just set to make sure it works.
  10. Swap the pg_hba.conf back to the previous version.




© 2023 Foray, LLC - All Rights Reserved