/
Reset lost PostgreSQL admin password

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.




Related content

Error Creating tables on PostgreSQL
Error Creating tables on PostgreSQL
More like this
Can't delete PostgreSQL database
Can't delete PostgreSQL database
More like this
PostgreSQL Timeout
PostgreSQL Timeout
More like this
Installation of PostgreSQL Error
Installation of PostgreSQL Error
More like this
Search and Replace in the Windows Registry
Search and Replace in the Windows Registry
More like this
Error: The transaction has aborted.
Error: The transaction has aborted.
More like this

© 2023 Foray, LLC - All Rights Reserved