How do you configure PostgreSQL to allow the default postgres user to login without a password from localhost?
There are several similar questions, such as this and this, but none of the suggestions to modify pg_hba.conf have worked for me. However, based on my understanding of the pg_hba.conf rules, I should be able to accomplish this with either the peer or trust options.
I'm trying to run a command like:
sudo psql --user=postgres --no-password --command="blah;" -h 127.0.0.1
If I try this line in my pg_hba.conf:
local all postgres trust
my command fails with the error:
psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "postgres", database "postgres", SSL on
FATAL: no pg_hba.conf entry for host "127.0.0.1", user "postgres", database "postgres", SSL off
If I tried this line:
local all postgres peer
my command fails with the same error.
How do I fix this?