How to reset the password of postgres user in PostgreSQL

  • KM03603063
  • 26-Feb-2020
  • 26-Feb-2020

Archived Content: This information is no longer maintained and is provided "as is" for your convenience.

Summary

How to reset the password of postgres user in PostgreSQL

Question

When it is needed to restart postgres password of the DB user, it should be needed to folow the steps in this KM

Answer

The file that should be modified is pg_hba.conf 

PostgreSQL uses the pg_hba.conf configuration file that is stored in the database data directory to control the client authentication. HBA means host-based authentication. To reset the password for the postgres user, it will be needed to modify some parameters in this configuration file. 

 

- Edit the pg_dba.conf 

- Change the below line: 

host    all              postgres           127.0.0.1/32            password 

to 

host    all              postgres           127.0.0.1/32            trust 

- Restart PostgreSQL DB service 

- Use psql to connect to PostgreSQL DB: psql -U postgres 

- ALTER USER postgres with encrypted password 'new_password'; 

These steps are required when customer doesn’t know any password of probe DB e.g. mamprobe or postgres.  

Then it will be needed to reset postgres / mamprobe password using the above steps.