1

So I forgot the password of the postgres user on my PostgreSQL server. I then changed all the md5 settings in the pg_hba.conf file to trust, restarted the server and then changed the password of the postgres user using ALTER USER postgres.... Now I changed the trust settings back to md5, restarted the server again, but when I now want to perform psql -U postgres it immediately returns an error:

psql: FATAL: password authentication failed for user "postgres"
password retrieved from file "/root/.pgpass"

without asking me to enter any password. The .pgpass file has the following line in it:

*:*:*:postgres:SOME_HASH

EDIT:

Somehow this only appears when logging in as root to my server... With my other user it works just fine...

3
  • 1
    It should be md5, not mb5 Commented Aug 11, 2020 at 4:47
  • Sorry. this was a typo here. changed it Commented Aug 11, 2020 at 4:49
  • Well, then remove the wrong password from /root/.pgpass Commented Aug 11, 2020 at 5:37

2 Answers 2

0

The immediate solution is to remove the .pgpass file that contains the wrong password. If you didn't create that file yourself, odds are that pgAdmin did that for you when you told it to save the password.

Sign up to request clarification or add additional context in comments.

Comments

0

If you specify '-W', then psql will prompt you for a password and ignore the .pgpass file. But why not fix .pgpass, or if you aren't using it, then remove it?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.