All we need is an easy explanation of the problem, so here it is.
I created a user john
with createuser
and didn’t supply any passwords for it, i.e. no -P
option specified. I then proceeded to add the following line above all other lines in the pg_hba.conf
file:
host all john 127.0.0.1/32 trust
I then restarted the server but even after that, when I try to run psql -U john
it keeps asking for a password. I even ran the command psql -c "alter role john with password null;"
but it changed nothing. PostgreSQL keeps asking for a password for john
. What am I missing?
Running PostgreSQL 13.2 on Windows 10.
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
Method 1
By checking the logs, it got apparent that PostgreSQL was matching the ::1/128
IPv6 address, which had scram-sha-256
as its authentication method. adding a line like
host all john ::1/128 trust
fixed the problem.
Also, there is no need for restarting the DBMS after changes to pg_hba.conf
.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0