Chris F
Chris F

Reputation: 16813

Changed postgres password, but can still access DB without password?

PostgeSQL v13.3 on a Windows host.

I ultimately want to do this as part of automation, but want to do it manually first.

I get into my DB by...

$ psql -U postgres
postgres=# ALTER postgres WITH PASSWORD 'mypassword';
ALTER ROLE
postgres=# quit

$ psql -U postgres
postgres=#

...or...

$ psql -U postgres -h localhost

and am NOT prompted for p/w in either case. If I do...

$ psql -U postgres -W
Password: <enter wrong p/w>
postgres=#

so above prompts me for a p/w, but I can enter anything and it will let me in!

I read Stackoverflow posts about this. like changing the pg_hba.conf file form

local all all peer

to

local all all md5

But I do have this in my pg_hba.conf file

local all all trust

Even if I change the value from trust to md5 and restart the service, it doesn't work.

what gives?

Upvotes: 0

Views: 211

Answers (1)

Chris F
Chris F

Reputation: 16813

I should've RTFM'ed the pg_hba.conf file. I changed everything from trust to md5 and it's prompting me now.

Upvotes: 3

Related Questions