Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have installed PostgreSQL on my Windows machine for development. Now I haven't used it for a while, and have forgotten the password for user postgres (default admin user in PostgreSQL). How can I reset the password for postgres in PostgreSQL on Windows?


I followed Milen's suggestion, but got this message when trying to reload the configuration file:

C:\Program Files\PostgreSQL\9.1\data>pg_ctl reload -D .
pg_ctl: could not send reload signal (PID: 3396): Operation not permitted

In Windows there is a menu option "Reload Configuration" that worked better, as shown below:

enter image description here

share|improve this question
    
There are suposed to be some free programs that may help, but had not try one. You may want to Google around for one or check here: http://www.ilikemall.com/guide/reset-windows-7-password.html –  frizz Gee Jan 14 '13 at 13:12
    
Hi frizz, thanks for answering, but I think you've missed the point of the question here: it is specifically the postgres password, not a Windows password that needs to be reset :) –  Jack Douglas Jan 14 '13 at 14:00
add comment

1 Answer 1

up vote 9 down vote accepted

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

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 / PASSWORD to set the new password
  4. Edit pg_hba.conf again and restore the previous settings
  5. Reload the config file again
share|improve this answer
    
Link-only answers are not helpful. Please summarize the content of the link and add some context. –  JNK Jun 21 '12 at 13:58
    
@Jonas It may have reverted when I deleted the undeleted the answer...sorry! –  JNK Jun 21 '12 at 14:01
    
@JNK: Ok, I added it again now. –  Jonas Jun 22 '12 at 7:44
1  
Why have you rolled back the edits? –  dezso Sep 26 '13 at 14:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.