致命:用户“postgres”的密码身份验证失败(带有 pgAdmin 4 的 postgresql 11)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/55038942/
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
FATAL: password authentication failed for user "postgres" (postgresql 11 with pgAdmin 4)
提问by Michelley
I recently installed Postgresql 11, during the installation, there's no step to put password and username for Postgres. Now in pgAdmin 4, I wanted to connect the database to server and it's asking me to input password, and I haven't put any in the first place. Any one knows what's going on. Thank you!
我最近安装了 Postgresql 11,在安装过程中,没有步骤为 Postgres 输入密码和用户名。现在在 pgAdmin 4 中,我想将数据库连接到服务器,它要求我输入密码,而我一开始没有输入密码。任何人都知道发生了什么。谢谢!
采纳答案by iLuvLogix
You could access your pgpass.conf via pgAdmin -> Files -> open pgpass.conf
你可以通过访问你的 pgpass.conf pgAdmin -> Files -> open pgpass.conf
That will give you the path of pgpass.conf
at the bottom of the window (official documentation).
这将为您提供pgpass.conf
窗口底部的路径(官方文档)。
If you then open this file and edit it to your liking.
如果您随后打开此文件并根据自己的喜好对其进行编辑。
If that doesn't work, you can:
如果这不起作用,您可以:
- Find your pg_hba.conf, usually in C:\Program Files\PostgreSQL\9.1\data\pg_hba.conf
- If necessary, set the permissions on it so that you can modify it; your user account might not be able to do so until you use the security tab in the properties dialog to give yourself that right by using an admin override.
- Alternately, find notepad / notepad++ in your start menu, right click, choose "Run as administrator", then use File->Open to open pg_hba.conf that way.
- Edit it to set the "host" line for user "postgres" on host "127.0.0.1/32" to "trust". You can add the line if it isn't there; just insert:
- 找到你的 pg_hba.conf,通常在 C:\Program Files\PostgreSQL\9.1\data\pg_hba.conf
- 如有必要,对其设置权限,以便您可以对其进行修改;您的用户帐户可能无法执行此操作,直到您使用属性对话框中的安全选项卡通过使用管理员覆盖为自己赋予该权限。
- 或者,在开始菜单中找到记事本/记事本++,右键单击,选择“以管理员身份运行”,然后使用文件->打开以这种方式打开 pg_hba.conf。
- 编辑它以将主机“127.0.0.1/32”上用户“postgres”的“host”行设置为“trust”。如果它不存在,您可以添加该行;只需插入:
host all postgres 127.0.0.1/32 trust
host all postgres 127.0.0.1/32 trust
before any other lines. (You can ignore comments, lines beginning with #).
在任何其他行之前。(您可以忽略注释,以# 开头的行)。
Restart the PostgreSQL service from the Services control panel (start->run->services.msc)
connect using psql or pgAdmin4 or whatever you prefer
- and run
ALTER USER postgres PASSWORD 'fooBarEatsBarFoodBareFoot'
- remove the line you added to pg_hba.conf or change it back
- restart PostgreSQL again.
从服务控制面板重启 PostgreSQL 服务 (start->run->services.msc)
使用 psql 或 pgAdmin4 或您喜欢的任何方式连接
- 并运行
ALTER USER postgres PASSWORD 'fooBarEatsBarFoodBareFoot'
- 删除您添加到 pg_hba.conf 的行或将其改回
- 再次重启 PostgreSQL。
回答by Drublic
I know this is an old question, but I had the same problem, e.g. no dialog for setting password for Postgres during installation with Postgresql 11.
我知道这是一个老问题,但我遇到了同样的问题,例如在安装 Postgresql 11 期间没有为 Postgres 设置密码的对话框。
Instead of doing all the file manipulations suggested in the other answers, I deleted Postgresql 11 and installed Postgresql 12, where I was prompted for setting password during installation.
我没有执行其他答案中建议的所有文件操作,而是删除了 Postgresql 11 并安装了 Postgresql 12,在安装过程中系统提示我设置密码。
回答by user1575148
Note: CREATE USER is the same as CREATE ROLE except that it implies LOGIN.
注意:CREATE USER 与 CREATE ROLE 相同,只是它隐含了 LOGIN。
$ psql postgres
postgres=# create user postgres with superuser password 'postgres';
回答by Pavan Patel
For Windows variant - I too experienced this nasty bug because of pgAdmin for my Windows x64 install of version 9.2. It left my production paralyzed.
对于 Windows 变体 - 我也遇到了这个讨厌的错误,因为我的 Windows x64 版本 9.2 安装的 pgAdmin。它使我的生产瘫痪。
In folder C:\Program Files\PostgreSQL\9.2\data or C:\Program Files (x86)\PostgreSQL\9.x\data, you'll find the pg_hba.conf text file.
在文件夹 C:\Program Files\PostgreSQL\9.2\data 或 C:\Program Files (x86)\PostgreSQL\9 中。x\data,您将找到 pg_hba.conf 文本文件。
Find the following lines:
找到以下几行:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
and change METHOD md5 to "trust" like this:
并将 METHOD md5 更改为“信任”,如下所示:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
From Windows>Run type "services.msc" and enterfind the right PostgreSQL instance and restart it.
从 Windows>Run 输入“services.msc”并enter找到正确的 PostgreSQL 实例并重新启动它。
Your DB security is now blown wide open! Heed the warning to return it back to md5 after changing the user password expiry time to say year 2099 for all the relevant users.
您的数据库安全性现已全面开放!在将所有相关用户的用户密码到期时间更改为 2099 年后,注意警告将其返回到 md5。
回答by Pushkaraj Bhandari
Follow below stepsif you are using pgAdmin4 and facing error in updating password :
如果您使用 pgAdmin4 并在更新密码时遇到错误,请按照以下步骤操作:
1] Open file "pg_hba.conf" and find "IPv4 local connections"
1]打开文件“pg_hba.conf”并找到“IPv4本地连接”
2] See the value under "Method" column, it must be set to "md5" becase you selected it while installing.
2]查看“方法”列下的值,它必须设置为“md5”,因为您在安装时选择了它。
3] Make "md5" value blank and save the file. Restart pgAdmin4 application.
3]将“md5”值设为空白并保存文件。重新启动 pgAdmin4 应用程序。
4] Now again set the value back to "md5" and input your password in pgAdmin application.
4] 现在再次将值设置回“md5”并在 pgAdmin 应用程序中输入您的密码。
You should be successfully able to do it.
你应该能够成功地做到这一点。