I found my posgresql database server is not asking password for user postgres
when remote connecting through pgadmin. I mean this is when I connect to remote database server from my local computer through pgAdmin.
I did add a password in psql, ALTER USER postgres PASSWORD 'mypassword'
.
This is my pg_hba.config file:
/usr/local/pgsql/bin/psql -qAt -c "show hba_file" | xargs grep -v -E '^[[:space:]]*#'
local all all trust
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
host all all ::1/128 md5
So, I do not quite understand what is happening here.
Can anyone help with this?
Thanks a lot.
UPDATE:
If i change:
local all all trust
to
local all all md5
Now, local connections (via SSH) will be asked for password ( wasn't asking for password before.) but remote connections will still connect without a password.
Acutally, I tried connecting to this database server by a rails appliaction from another server, without a password, and the rails server started without a problem.
PUTTING RESULT HERE FOR THE CONVENIENCE
The real reason of this issue was the .pgpass
file. Mac stored the password locally in the .pgpass
file under user home folder. Then every time when user try to login without a password, PostgreSQL will send the password for user.
Official doc here
ALTER USER postgres PASSWORD 'mypassword'
. – Yunwei.W Jan 9 '14 at 6:14127.0.0.1
or connect from a remote host? If you're connecting over unix socket, with your configuration, no password prompt should be expected because you're usingtrust
mode ffor unix sockets (local
). – Craig Ringer Jan 9 '14 at 6:53