【问题标题】:pgadmin4 unable to connect to server,FATAL: password authentication failed for user "postgres"pgadmin4 无法连接到服务器,致命:用户“postgres”的密码验证失败
【发布时间】:2021-07-03 02:41:24
【问题描述】:

我尝试将 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 应用程序和 url 去这个:http://127.0.0.1:60888/browser/

this is my pgadmin4 in browser

【问题讨论】:

  • 您展示的 pg_hba 永远不会尝试密码验证,因此它不会失败。您似乎没有尝试连接到您认为的服务器。

标签: postgresql pgadmin pgadmin-4


【解决方案1】:

我在修改 pg_hba.conf 后解决了

来自

local   all             all                                     trust

成为

host   all             all                                     trust

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

【讨论】:

    【解决方案2】:

    在 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://docs.boundlessgeo.com/suite/1.1.1/dataadmin/pgGettingStarted/firstconnect.html

    【讨论】:

    • 您好,感谢您的回答,但我仍然遇到同样的错误,我尝试了您的方法,尝试使用 psql -U postgres -W 测试连接,它可以工作
    • 我的意思是连接成功,但是在 pgadmin 网络浏览器(我的笔记本电脑)中没有工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2020-09-18
    • 2020-10-13
    • 1970-01-01
    相关资源
    最近更新 更多