Resetting main PostgreSQL password

Sometimes we can forget main password for PostgreSQL.

We should edit config file:

vim /etc/postgresql/<version>/main/pg_hba.conf

local   all             postgres                                peer

Restart postgresql service, so the configuration will take affect:

service postgres restart

Login on postgresql:

postgres psql

#set new password
ALTER USER postgres PASSWORD 'new_password';

Remember to recover original setting of pg_hba.conf

Leave a Reply

Your email address will not be published. Required fields are marked *

*