我正在尝试远程访问安装在 IP AAAA 的服务器上的 postgresql 有两台服务器,其中一台具有 IP AAAA,其中安装了 postgresql;另一个有IP BBBB
我已经编辑/etc/postgresql/10/main/pg_hba.conf
并添加了以下几行
host my_db db_user B.B.B.B/32 md5
host my_db db_user A.A.A.A/32 md5
我还编辑/etc/postgresql/10/main/postgresql.conf
并设置listen_addresses
为'*'
,如下所示:
#---------------------------------------------------------------------
---------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
我还允许通过 ufw 中的端口 5432 进行连接:
5432 ALLOW Anywhere
5432 (v6) ALLOW Anywhere (v6)
现在,如果我在服务器 A 中(安装了 postgres)并执行 psql"postgresql://db_user:password@A.A.A.A:5432/my_db"
它连接正常。但是,如果我使用 IP BBBB 从服务器执行此操作,则会收到此错误:
psql: FATAL: no pg_hba.conf entry for host "B.B.B.B", user "db_user", database "my_db", SSL on
FATAL: no pg_hba.conf entry for host "B.B.B.B", user "db_user", database "my_db", SSL off
我真的不明白错误在哪里。两个条目pg_hba.conf
看起来相同,但一个有效,另一个无效。