This tutorial work for Windows. For Linux, click here.

  1. Find file pg_hba.conf. its here:
    C:\Program Files\PostgreSQL\9.1\data
  2. Open, and modifiy this line:
    #this for IPv4
    host all all 127.0.0.1/32 trust
    #this for IPv6
    host all all ::1/128 trust
  3. Restart PostgreSQL service
  4. After that, login to database as postgres. Note that ‘postgres’ is root user. Now you won’t be asked for the password
  5. execute this query:
    ALTER USER postgres WITH PASSWORD ‘<your-new-password>’;
    example:
    ALTER USER postgres WITH PASSWORD ‘bayu’;
  6. Open file pg_hba.conf again, then modify this line
    #this for IPv4
    host all all 127.0.0.1/32 md5
    #this for IPv6
    host all all ::1/128 md5
  7. Restart PostgreSQL service
  8. Now you can login using new password