加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 无法从我的Mac连接到VM上的PSQL数据库

发布时间:2020-12-14 03:01:42 所属栏目:Linux 来源:网络整理
导读:尝试使用pgAdmin3从我的Mac上连接到我的CentOS VM上的PSQL数据库.出现以下错误: Access to database deniedThe server doesn't grant access to the database: the server reports FATAL: no pg_hba.conf entry for host "172.16.30.1",user "gpadmin",data
尝试使用pgAdmin3从我的Mac上连接到我的CentOS VM上的PSQL数据库.出现以下错误:
Access to database denied
The server doesn't grant access to the database: the server reports 
FATAL: no pg_hba.conf entry for host "172.16.30.1",user "gpadmin",database "postgres",SSL off

VM的IP地址是172.16.30.139,因此我将其用作主机.我在pg_hba.conf文件中添加了以下内容:

local all     gpadmin     ident
#host all     gpadmin     127.0.0.1/28      trust
#host all     gpadmin     192.168.249.131/32    trust
local gpperfmon   gpmon                             md5
host     all     all     192.168.2.109   md5

其中192.168.2.109是我的Mac内部IP地址.

任何帮助,将不胜感激.

编辑:

我还运行了一个tcpdump然后尝试连接并查看以下日志(但我不知道如何阅读它们):

11:00:03.740455 IP 172.16.30.1.58043 > 172.16.30.139.postgres: S 3397342885:3397342885(0) win 65535 <mss 1460,nop,wscale 3,timestamp 837321186 0,sackOK,eol>
11:00:03.740500 IP 172.16.30.139.postgres > 172.16.30.1.58043: S 3408844558:3408844558(0) ack 3397342886 win 5792 <mss 1460,timestamp 74855527 837321186,wscale 7>
11:00:03.740630 IP 172.16.30.1.58043 > 172.16.30.139.postgres: . ack 1 win 65535 <nop,timestamp 837321186 74855527>
11:00:03.740650 IP 172.16.30.1.58043 > 172.16.30.139.postgres: P 1:9(8) ack 1 win 65535 <nop,timestamp 837321186 74855527>
11:00:03.740660 IP 172.16.30.139.postgres > 172.16.30.1.58043: . ack 9 win 46 <nop,timestamp 74855527 837321186>
11:00:03.744513 IP 172.16.30.139.postgres > 172.16.30.1.58043: P 1:2(1) ack 9 win 46 <nop,timestamp 74855531 837321186>
11:00:03.744740 IP 172.16.30.1.58043 > 172.16.30.139.postgres: . ack 2 win 65535 <nop,timestamp 837321190 74855531>
11:00:03.744816 IP 172.16.30.1.58043 > 172.16.30.139.postgres: P 9:88(79) ack 2 win 65535 <nop,timestamp 837321190 74855531>
11:00:03.746083 IP 172.16.30.139.postgres > 172.16.30.1.58043: P 2:148(146) ack 88 win 46 <nop,timestamp 74855533 837321190>
11:00:03.746318 IP 172.16.30.1.58043 > 172.16.30.139.postgres: . ack 148 win 65535 <nop,timestamp 837321191 74855533>
11:00:03.749231 IP 172.16.30.139.postgres > 172.16.30.1.58043: F 148:148(0) ack 88 win 46 <nop,timestamp 74855536 837321191>
11:00:03.749471 IP 172.16.30.1.58043 > 172.16.30.139.postgres: . ack 149 win 65535 <nop,timestamp 837321194 74855536>

解决方法

192.168.2.109可能是您内部网络上的mac地址,但172.16.30.1是虚拟网络上用于与VM通信的mac地址,这是您需要在pg_hba.conf中配置的地址.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读