Would you like to learn how to recover the PostgreSQL admin password? In this tutorial, we are going to show you how to use the PostgreSQL password recovery procedure to change the password of the postgres user using the command-line of a computer running Ubuntu Linux.
• Ubuntu 18.04
• Ubuntu 19.04
• PostgreSQL 11.5
PostgreSQL Related Tutorial:
On this page, we offer quick access to a list of tutorials related to PostgreSQL.
Tutorial – PostgreSQL Password Recovery
Locate and edit the pg_hba.conf configuration file.
Keep in mind that your pg_hba.conf file location may not be the same as mine.
Add the following line at the beginning of this file.
Here is our pg_hba.conf file content:
Restart the PostgreSQL service.
You are now able to access the PostgreSQL service locally without entering any password.
Change the postgres account password and quit.
In our example, we changed the postgres user password to admin.
Edit the pg_hba.conf configuration file and remove the line we previously added.
Here is our pg_hba.conf file content:
Restart the PostgreSQL service.
Congratulations! You successfully recovered the password of the PostgreSQL Admin user.