postgresql psql.exe - Windows 中的密码验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12562928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
psql.exe - password authentication failed in windows
提问by user1184100
I'm a noob in PostgreSQL. I installed ver 9.2 on windows7. During installation it asked for password and i entered it. Now whenever i run d:\tools\PostgreSQL9.2\bin\psql.exe it asks for password. When i enter the password it doesn't accept and it shows "password authentication failed for user "user1". I have re-installed twice already. Also i tried entering my system password.
我是 PostgreSQL 的菜鸟。我在 windows7 上安装了 9.2 版。在安装过程中它要求输入密码,我输入了它。现在,每当我运行 d:\tools\PostgreSQL9.2\bin\psql.exe 时,它都会要求输入密码。当我输入密码时,它不接受并显示“用户“user1”的密码身份验证失败。我已经重新安装了两次。我也尝试输入我的系统密码。
I'm trying to get the below command to work
我正在尝试使以下命令起作用
psql.exe -f db/codedb.sql development
What should i do to get this working ?
我应该怎么做才能让它工作?
回答by Richard Huxton
Try setting the user name when connecting.
连接时尝试设置用户名。
psql.exe -U username -d dbname -f somefile.sql
You've probably set up the default "postgres" user during installation. Not sure if you've created any others.
您可能在安装过程中设置了默认的“postgres”用户。不确定您是否创建了任何其他人。
To add other users and databases just connect to as postgres to the postgres database and do something like:
要添加其他用户和数据库,只需作为 postgres 连接到 postgres 数据库并执行以下操作:
CREATE USER myuser WITH ENCRYPTED PASSWORD 'secret';
CREATE DATABASE mydb OWNER myuser;
If your machine is secure you might also like to set up a password file
如果您的机器是安全的,您可能还想设置一个密码文件
回答by solaimuruganv
change "trust" instead of "md5" in the pg_hba.conf to connect to the database and change your password.
在 pg_hba.conf 中更改“trust”而不是“md5”以连接到数据库并更改密码。
--------------------configuration in pg_hba.conf---------------
local all all trust
local all postgres trust
host all all ::1/128 trust
回答by KIRAN KOORA
Here is the simple solution for installation Postgresql without getting errors(cluster errors and authentication errors),i have followed below steps and i got installed postgresql sucessfully
这是安装 Postgresql 的简单解决方案,没有出现错误(集群错误和身份验证错误),我按照以下步骤操作并成功安装了 postgresql
create new user in windows from controlpanel-->user accounts
After logged into new user(whic u hve created) copy postrgresql(.exe) application into any directory(other than 'C') and click on the application to install(dont forget to change the installation directory to which u have copied the application file above).
after completion of installaion change below configurations in postgresql.conf and pg_hba.cof
从控制面板-> 用户帐户在 Windows 中创建新用户
登录新用户(您创建的用户)后,将 postrgresql(.exe) 应用程序复制到任何目录('C' 除外)并单击该应用程序进行安装(不要忘记更改您已将应用程序复制到的安装目录)上面的文件)。
安装完成后更改 postgresql.conf 和 pg_hba.cof 中的配置
add like below in your postgresql.conf
在您的 postgresql.conf
listen_addresses = '*'
add like below in your pg_hba.cof
在您的 pg_hba.cof
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
# host sameuser postgres 127.0.0.1/32 trust
#host replication postgres ::1/128 md5