pgadmin4 无法连接到服务器,致命:用户“postgres”的密码身份验证失败

问题描述

我尝试配置 postgresql 以便能够“远程”连接到 pgadmin4 所以我在服务器中安装了 postgresql 版本 13,并尝试通过我的笔记本电脑访问它。

但是为什么我总是出错,我只是更改了密码,然后在 pgadmin4 中输入了用户名和密码,它仍然显示密码验证。

image1

这是我的 pghba.conf 文件

# TYPE  DATABASE        USER            ADDRESS                 METHOD

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

这是我的 postgesql.conf 文件

listen_addresses = '*'
                    # comma-separated list of addresses;
                    # defaults to 'localhost'; use '*' for all
                    # (change requires restart)
port = 5434             # (change requires restart)
max_connections = 100           # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '/var/run/postgresql,/tmp'  # comma-separated list of directories
                    # (change requires restart)
#unix_socket_group = ''         # (change requires restart)
#unix_socket_permissions = 0777     # begin with 0 to use octal notation
                    # (change requires restart)
#bonjour = off              # advertise server via Bonjour
                    # (change requires restart)
#bonjour_name = ''          # defaults to the computer name
                    # (change requires restart)

# - TCP settings -
# see "man tcp" for details

#tcp_keepalives_idle = 0        # TCP_KEEPIDLE,in seconds;
                    # 0 selects the system default
#tcp_keepalives_interval = 0        # TCP_KEEPINTVL,in seconds;
                    # 0 selects the system default
#tcp_keepalives_count = 0       # TCP_KEEPCNT;
                    # 0 selects the system default
#tcp_user_timeout = 0           # TCP_USER_TIMEOUT,in milliseconds;
                    # 0 selects the system default

# - Authentication -

#authentication_timeout = 1min      # 1s-600s
password_encryption = scram-sha-256     # md5 or scram-sha-256
#db_user_namespace = off

# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
#krb_caseins_users = off

我仍然不知道为什么,也许有人经历过同样的事情?或者有什么想法? 仅供参考:我打开 pgadmin4 应用程序和指向此的网址:http://127.0.0.1:60888/browser/

this is my pgadmin4 in browser

解决方法

在 image1 上,您更改了 Postgres linux 用户的密码,而不是 Postgres 数据库用户的密码。尝试下一步:

sudo -u postgres psql postgres # connect to Postgres
\password postgres # change password postgres user
\q # quite from Postgres shell

然后再次尝试连接到 Postgres。

会有所帮助:https://github.com/elastic/elasticsearch-py/issues/1333

,

我在 pg_hba.conf 中更改后解决了

来自

local   all             all                                     trust

成为

host   all             all                                     trust

现在它就像一个魅力..谢谢大家! :)