Sunday 15 March 2015

How to change Postgres Admin Password ?



To do this using command prompt. It is good to know that in windows there will be 2 account. One is postgres windows user account. The other is database admin account. Which is also called postgres.


  • Edit E:\PostgreSQL\9.1\pg_hba.conf and set the localhost method to trust instead of md5.  Do not forget to save.
  • Use the usual Windows way to reset the password of windows user account.
  • Open up a command prompt and use runas to open another command prompt as postgres user.
  • open up Services manager and restart postgresql service. There might be need to update the postgres user account password setting in the service property at this step.
  • Now running psql will not ask any password.
  • Use the following sql to set the user password

ALTER USER Postgres WITH PASSWORD '<newpassword>'

  • Revert the pg_hba.conf localhost method back to md5 .
  • Restart postgresql service in Services manager.