How Do I Recover/Reset the Postgres Password?

How Do I Recover/Reset the Postgres Password?

I have forgotten the password that I used while installing postgres. It asks for the password for every action I perform. What can I do in this case?

I've even tried removing postgres and reinstalling it again, but it still asks for the password.

1

1 Answer

In general you can use the following procedure: Go to the terminal and type:

sudo -u postgres psql

When you're logged in and the psql prompt appears then issue this SQL command:

ALTER USER postgres PASSWORD 'newpassword';

This may have consequences for any software using these login details too, so check if everything is still working after doing this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.