I'm using PostgreSQL 9.6.2 on Windows 7 and when I start psql from the command prompt with:
psql -U myusername
it asks for a password just fine and logs in. However if I do:
psql -U postgres
it's gonna log in directly to the main database with superuser rights without asking for any kind of password. If I type in:
psql -U postgres -W
then it's gonna ask for the su password which is by the way the one that I set during the one-click installation.
I've checked the pg_hba.conf
and it's set to md5
for all users, all databases. I've even changed the password from the db with: postgres=# ALTER USER postgres PASSWORD 'myPassword';
, to no avail.
The question is why when I log as a normal user it asks for a password and doesn't when i log as superuser? It's not a major issue as I can access my databases in either case, but it just doesn't seem safe at all. Any workaround would be very much appreciated.
pgpass.conf
? postgresql.org/docs/current/static/libpq-pgpass.htmlpg_hba.conf
? I mean all lines that are not commented out.pgpass.conf
and the postgres password was indeed stored there in plain text. I commented the lines out and now psql prompts for password when I login as postgres.