psql: 致命: 用户 windows 8 的密码验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31028623/
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: FATAL: password authentication failed for user windows 8
提问by Sarah cartenz
I installed postgresql on windows and while the installation it asks to make a user for the account.This made a new windows user in my computer called postgres, I have created a password for it as well.
我在 Windows 上安装了 postgresql,安装时它要求为该帐户创建一个用户。这在我的计算机中创建了一个名为 postgres 的新 Windows 用户,我也为它创建了一个密码。
Now I want to run psql on windows command line, it asks for a password (without mentioning the user) and always gives me back the error: psql: FATAL: password authentication failed for user "Ash".
Even though I have put my accounts password many times.
现在我想在 windows 命令行上运行 psql,它要求输入密码(没有提到用户)并且总是给我回错误:psql: FATAL: password authentication failed for user "Ash".
即使我已经多次输入我的帐户密码。
using pgadmin I changed the user "postgres" to "Ash" but I have yet to remake the password. I followed the steps here: I forgot the password I entered during postgres installation(I rather types host all 127.0.0.1/32 trust
because I am on windows), but when running psql again so that I can change the password I get the error: psql FATAL:could not load pg_hba.conf.
All together.
使用 pgadmin 我将用户“postgres”更改为“Ash”,但我还没有重新设置密码。我按照这里的步骤操作:我忘记了在 postgres 安装过程中输入的密码(我更喜欢输入,host all 127.0.0.1/32 trust
因为我在 Windows 上),但是当再次运行 psql 以便我可以更改密码时,我收到错误:psql FATAL:could not load pg_hba.conf.
All together。
Why can it not load? All I did was add an extra authentication option.
为什么加载不出来?我所做的只是添加了一个额外的身份验证选项。
Also, is the windows user separated from a postresql user or are they the same(depend on each other)?
另外,windows 用户与 postresql 用户是分开的还是相同的(相互依赖)?
Edit:
编辑:
As you can see, it did not give me the option to choose if Aisha should be a superuser or not. or the other options for that matter.
如您所见,它没有让我选择 Aisha 是否应该成为超级用户。或其他选项。
I also used pgadmin||| to create a new user but the same error pops up:
我也用过pgadmin||| 创建一个新用户,但弹出相同的错误:
The user does not exist so why does it do this?
用户不存在,为什么要这样做?
回答by Sami Kuhmonen
The user on your machine has nothing to do with the user on PostgreSQL. The installer just creates an account and a PostgreSQL role with the same name and password (which in my mind is a bad idea), but they're not related in any way. The Windows user is used to run the server, the PostgreSQL role is used inside the database.
您机器上的用户与 PostgreSQL 上的用户无关。安装程序只是创建一个帐户和一个具有相同名称和密码的 PostgreSQL 角色(在我看来这是一个坏主意),但它们没有任何关系。Windows 用户用于运行服务器,PostgreSQL 角色用于数据库内部。
So you should first access the server with the user postgres and then create a user for yourself. Don't change the username inside the server, or the server's running user! Just create a new username and grant it the permissions you need.
所以你应该首先使用用户 postgres 访问服务器,然后为自己创建一个用户。不要更改服务器内部的用户名,或服务器的运行用户!只需创建一个新用户名并授予它所需的权限即可。
You can use psql -U postgres
to connect to the server and it'll ask for the password.
您可以使用psql -U postgres
连接到服务器,它会要求输入密码。
Check the permissions for pg_hba.conf, the postgres user must have permissions for it. If you only edited it as an admin, it should be ok, but if you took permissions or anything else, it may mess it up.
检查 pg_hba.conf 的权限,postgres 用户必须有权限。如果你只是以管理员身份编辑它,应该没问题,但如果你获得了权限或其他任何东西,它可能会搞砸。
回答by Craig Ringer
createuser
is a command-line utility. Use CREATE USER username WITH PASSWORD 'fred';
or similar at the SQL level in psql
. Note the semicolon.
createuser
是一个命令行实用程序。使用CREATE USER username WITH PASSWORD 'fred';
或在SQL水平相似psql
。注意分号。
What you're doing in your screenshot is starting to write an SQL command beginning with createuser
, but never sending it to the server to run because there's no semicolon terminator. So you never get the error that would tell you it doesn't make sense to do that.
您在屏幕截图中所做的是开始编写以 开头的 SQL 命令createuser
,但从未将其发送到服务器以运行,因为没有分号终止符。所以你永远不会得到告诉你这样做没有意义的错误。
回答by Aladdin DJOUAMA
I had exactly the same problem and this line solved it;
我遇到了完全相同的问题,这条线解决了它;
createuser --createdb -U postgres --login -P 'your_new_user'
@sami-kuhmonen was right, but his approach of solving the problem did not work for me.
@sami-kuhmonen 是对的,但他解决问题的方法对我不起作用。