Reputation: 876
I work with PostgreSQL 9.2 and have command:
psql -h localhost -U testdb -d postgis
This command has the ability to connect database without password. I want to enter a password.
My pg_hba.cconf
is:
local all all password
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
Upvotes: 1
Views: 204
Reputation: 656706
Password-less access requires that one of several authentication methods is configured accordingly. More details in these related answers:
pgadmin gives me the error: no password supplied
Run batch file with psql command without password
In particular, localhost
is not a "local connection" in the pg_hba.conf
file in the second one. Since you are connecting with -h localhost
, only the lines starting with host
in your pg_hba.conf
file are applicable, so a password should be required.
Remaining explanations:
You did not reload
since the config file was changed.
You are not showing the right (or complete) pg_hba.conf
(or inadvertently connecting to the wrong db cluster. Port 5432?) and there is in fact a line with peer
or ident
authentication that comes before other host
lines.
Your installation has a .pgpass
file in place, that grants access to the system user you are running the command with. For details, refer to the second linked answer.
The last one seems most likely.
Upvotes: 1