简体   繁体   中英

Windows psql wrong password in cmd/powershell

I recently came across a very interesting issue.

When I wanted to access 'psql' through cmd, it reported wrong password for user 'postgres'. Pre-defined psql shell that come bundled with server installation worked. Setting pg_hba.conf to trust didn't work either. Nor did heroku command (I tried to pull a remote database to local).

The problem was I had my port set to 5433 from the installation. For some reason psql command doesn't read port from postgresql.conf. Maybe there is a way to change that behavior, but the solution I went with was changing port in data\\postgresql.conf to 5432 and restarting the server. While the bundled psql shell doesn't work now, cmd and heroku are able to connect!

Though you already have solved your problem, it may be useful for someone to try start psql in cmd/powershell/any shell like:

psql postgresql://username:password@dbhost:dbport/dbname

It may help when it's essential to start psql or execute some command (by using "-c" attriblute) without prompting password.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM