pg Admin 4 - “postgres"的密码;尝试连接到 PostgreSQL 13 服务器时的用户 [英] pg Admin 4 - password for "postgres" user when trying to connect to PostgreSQL 13 server

查看:706
本文介绍了pg Admin 4 - “postgres"的密码;尝试连接到 PostgreSQL 13 服务器时的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题也有人问过,但我没有找到解决这个问题的方法!

I know that this question has been asked other times but I didn't find a solution to this problem!

我用 pg Admin 4 下载了 PostgreSQL 13,当我在安装后第一次打开它时,它会询问我在安装过程中被要求设置的主密码,在我提供主密码并且这被接受后我尝试连接到安装期间创建的默认服务器:PostgreSQL 13".

I downloaded PostgreSQL 13 with pg Admin 4 and when I open it for the first time after installation it asks me for the master password that I was asked to set during installation, after I give the master password and this gets accepted I try to connect to the default server created during the installation: "PostgreSQL 13".

此时,它要求我输入用户postgres"的密码.我不知道在哪里可以找到.具体来说,它说:请输入用户postgres"的密码以连接服务器-PostgreSQL 13".

At this point, it asks me for a password for the user "postgres" that I don't know where to find. Specifically, it says: Please enter the password for the user 'postgres' to connect the server - "PostgreSQL 13".

我已经尝试了所有的默认"我设法在互联网上找到的密码,但错误总是一样的:

I've already tried all the "default" passwords I managed to find on the internet but the error is always the same:

致命:用户postgres"的密码验证失败

FATAL: password authentication failed for user "postgres"

我也试过不插入任何密码并导致错误:

I've also tried not to insert any password with the resulting error:

fe_sendauth:未提供密码

fe_sendauth: no password supplied

我不知道该怎么办.在 PostgreSQL 13 中,认证方法通过 scram-sha-256 加密.我已经尝试将方法设置为信任,重新启动 mac,然后打开 pg Admin 4,它不断询问我访问服务器的密码.

I don't know what to do. In PostgreSQL 13 the authentication method is encrypted via scram-sha-256. I already tried to set the method to trust, restart the mac, and open pg Admin 4 that keeps asking me for the password to access the server.

我也尝试过使用命令行工具,但最终遇到了同样的错误.

I've also tried to use the command line tool but end up encountering the same errors.

最后,这是我的 pg_hba.conf 的样子:

Finally, this is how my pg_hba.conf looks like:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     scram-sha-256
# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     scram-sha-256
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

附注.我还尝试卸载 PostgreSQL 13,删除 postgres 用户并重新下载并重新安装所有内容......没有任何改变.

PS. I've also tried to uninstall PostgreSQL 13, deleting the postgres user and re-download and re-install everything... nothing changed.

如果有人能帮我就成为我的救星,谢谢!

If someone could help me would become my savior, thanks beforehand!

推荐答案

我最近遇到了同样的问题.下面的解决方案对我有用.顺便说一句,我使用的是 Windows,所以你应该在你的操作系统中尝试等效的命令.

I ran into the same problem recently. The solution below works for me. I'm using Windows btw, so you should try equivalent commands in your OS.

  1. pg_hba.conf 文件中所有行的 METHODscram-sha-256 更改为 trust
  2. 将Postgres安装的bin文件夹添加到路径中,如果你还没有
  3. 打开命令提示符并输入 psql -U postgres.此处不会要求您输入密码.
  4. 输入\password postgres
  5. 选择并确认您的密码
  6. pg_hba.conf 恢复到原始状态
  1. Change METHOD of all rows in your pg_hba.conf file from scram-sha-256 to trust
  2. Add bin folder of Postgres installation to path, if you haven't
  3. Open command prompt and enter psql -U postgres. You won't be asked for password here.
  4. Enter \password postgres
  5. Choose and confirm your password
  6. Revert pg_hba.conf to original state

现在您应该可以在 pgAdmin 中输入 postgres 的密码了.

Now you should be able to enter password for postgres in pgAdmin.

这篇关于pg Admin 4 - “postgres"的密码;尝试连接到 PostgreSQL 13 服务器时的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆