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
As an alternative you can go to Control Panel -> Systems and Security -> Windows Firewall -> Allow a program or feature through Windows Firewall -> Advanced Settings -> New Rule: Rule Type: Port. TCP or UDP: TCP. Specific local ports: 5432.
For most systems, the default Postgres user is postgres and a password is not required for authentication. Thus, to add a password, we must first login and connect as the postgres user.
Thanks for all the comments and answers ppl!
But the real reason of this issue was the .pgpass
file. My mac stored the password locally in the .pgpass
file under my user home folder. Then every time when i try to login without a password, PostgreSQL will send the password for me.
So that was the issue i was having....
Thanks for all the reply and the comments again!
For more details can refer to here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With