Reputation: 741
I have an issue with my PostgreSQL - the psql.exe
ignores anything I write as password for it.
What I do so far:
I run a simple (Powershell) script to start Postgre:
Start-Process -FilePath "C:\Program Files\PostgreSQL\pg95\bin\pg_ctl.exe" `
'start -D "C:\Program Files\PostgreSQL\data\pg95"''
With that running, I can now access the database with something like this:
& "C:\Program Files\PostgreSQL\pg95\bin\psql.exe" `
--dbname=$databaseName --host=$dbHost --username=$userName -c $sqlString
But most unfourtunately the terminal does not prompt me for a password!
This is odd, since psql.exe --help
gives the line:
..
-W, --password: force password prompt (should happen automatically)
But it does not.
When I try applying -W
it prompts me, but ignores what I write, and lets me access the database.
So the solution could be, that %appdata%\Postgresql\pgpass.conf
set the password, but it's empty.
Another solution is the environmental variable PGPASSWORD
is set, but I can't see it set anywhere. I tried Get-ChildItem Env:
in Powershell, and set
in cmd, but neither have it set.
Any suggestions are welcomed.
Upvotes: 0
Views: 1388
Reputation: 741
Shortest, but most helpful answer I've ever seen, @abelisto.
My pg_hba.conf
, located under c:\Program Files\PostgreSQL\data\pg95\
said:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# IPv4 local & remote connections:
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 trust
From Abelisto's link trust
is defined as:
Allow the connection unconditionally. This method allows anyone that can connect to the PostgreSQL database server to login as any PostgreSQL user they wish, without the need for a password or any other authentication.
Switching them to md5
gave a better result:
Require the client to supply a double-MD5-hashed password for authentication.
Upvotes: 2