2

How to change password of postgres user in windows server 2012 r2, I tried change md5 to trust in pg_hba.conf file & restart postgres services but still it asks password while connecting from command line or console.

screenshots

pg_hba.conf & pgAdm-console

Caterpillar
  • 1,132
  • 2
  • 23
  • 47

1 Answers1

2

From the 9.0 FAQ http://wiki.postgresql.org/wiki/FAQ#I_lost_the_database_password._What_can_I_do_to_recover_it.3F

I lost the database password. What can I do to recover it?

You can't. However, you can reset it to something else. To do this, you

  1. Edit pg_hba.conf to allow trust authorization temporarily
  2. Reload the config file (pg_ctl reload)
  3. Connect and issue ALTER ROLE postgres WITH PASSWORD 'newpassword'; to set the new password (for first time users note the semi-colon)
  4. Edit pg_hba.conf again and restore the previous settings Reload the config file again
Net Runner
  • 6,169
  • 12
  • 34
  • 2
    Fantabulous.... :) Did Worked indeed... Thanks ton. Reload the config file (pg_ctl reload) means D:\postgres8.4\bin>pg_ctl.exe F:\postgres8.4\data\ – Caterpillar Jan 11 '17 at 10:16