简体   繁体   English

Windows PSQL cmd / powershell中的密码错误

[英]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'. 当我想通过cmd访问“ psql”时,它报告了用户“ postgres”的错误密码。 Pre-defined psql shell that come bundled with server installation worked. 与服务器安装捆绑在一起的预定义psql shell可以正常工作。 Setting pg_hba.conf to trust didn't work either. 将pg_hba.conf设置为信任也不起作用。 Nor did heroku command (I tried to pull a remote database to local). heroku命令也没有(我试图将远程数据库拉到本地)。

The problem was I had my port set to 5433 from the installation. 问题是我从安装中将端口设置为5433。 For some reason psql command doesn't read port from postgresql.conf. 由于某些原因,psql命令不会从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. 也许有一种方法可以更改这种行为,但是我所采用的解决方案是将data \\ postgresql.conf中的端口更改为5432并重新启动服务器。 While the bundled psql shell doesn't work now, cmd and heroku are able to connect! 虽然捆绑的psql shell现在无法使用,但cmd和heroku可以连接!

Though you already have solved your problem, it may be useful for someone to try start psql in cmd/powershell/any shell like: 尽管您已经解决了问题,但是对于尝试在cmd / powershell /任何shell中启动psql的人来说可能很有用:

psql postgresql://username:password@dbhost:dbport/dbname psql postgresql://用户名:密码@dbhost:dbport / dbname

It may help when it's essential to start psql or execute some command (by using "-c" attriblute) without prompting password. 在必须启动psql或执行某些命令(通过使用“ -c”属性)而不提示输入密码时,它可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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