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.

Copy to Clipboard

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.

Copy to Clipboard

Here is our pg_hba.conf file content:

Copy to Clipboard

Restart the PostgreSQL service.

Copy to Clipboard

You are now able to access the PostgreSQL service locally without entering any password.

Copy to Clipboard

Change the postgres account password and quit.

Copy to Clipboard

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:

Copy to Clipboard

Restart the PostgreSQL service.

Copy to Clipboard

Congratulations! You successfully recovered the password of the PostgreSQL Admin user.