[英]psql - Mac trying to connect postgreSQL in Ubuntu system installed in a virtual machine in remote server
Apologize in front, maybe the situation here is a bit complicated. 在前面道歉,也许这里的情况有点复杂。 I searched everywhere online but couldn't find a perfect solution, plus I have tried almost all the solutions mentioned in other posts.
我在网上到处搜索,但找不到完美的解决方案,而且我尝试了其他帖子中提到的几乎所有解决方案。
So I have a postgreSQL database installed in a Ubuntu system. 所以我在Ubuntu系统中安装了一个postgreSQL数据库。 The system is actually a virtual machine on the VMware workstation 12, which is installed on Windows 7 professional.
该系统实际上是VMware工作站12上的虚拟机,该工作站安装在Windows 7 Professional上。 Now I am trying to remotely access the postgreSQL database through my MacBook pro 2013.
现在,我尝试通过MacBook Pro 2013远程访问postgreSQL数据库。
In the Mac terminal, the command line I tried is: 在Mac终端中,我尝试过的命令行为:
psql -U postgres -h xxx.xxx.xxx.xx
psql -U postgres -h xxx.xxx.xxx.xx
"xxx.xxx.xxx.xx" represents the IP address of the Windows 7 machine. “ xxx.xxx.xxx.xx”代表Windows 7计算机的IP地址。 The result is a failure:
结果是失败:
psql: could not connect to server: Operation timed out Is the server running on host "169.254.121.2" and accepting TCP/IP connections on port 5432?
psql:无法连接到服务器:操作超时服务器是否在主机“ 169.254.121.2”上运行并接受端口5432上的TCP / IP连接?
What I have done: 我做了什么:
host all all 0.0.0.0/0 md5
托管所有0.0.0.0/0 md5
listen_addresses='*'
listen_addresses ='*'
PORT STATE SERVICE
港口国服务
5432/TCP open postgresql
5432 / TCP打开PostgreSQL
Somehow managed to get it working.. 不知何故设法使其正常工作。
So when I ran "Nmap" on the other Ubuntu system towards this one, it does shows 因此,当我在另一个Ubuntu系统上针对该系统运行“ Nmap”时,它确实显示
PORT STATE SERVICE
港口国服务
5432/TCP open postgresql
5432 / TCP打开PostgreSQL
However, when I ran "Nmap" on my Mac, it's a different port, 3389, which is mainly used for Windows remote desktop. 但是,当我在Mac上运行“ Nmap”时,它是另一个端口3389,主要用于Windows远程桌面。 So what I did was to check the network configuration of this Ubuntu virtual machine from " bridged " to " NAT " and did a port forwarding to 5432. It is working fine now..
因此,我要做的就是检查此Ubuntu虚拟机从“ 桥接 ”到“ NAT ”的网络配置,并进行端口转发到5432。现在工作正常。
I read in some places saying that VMware favors bridged whereas VirtualBox favors NAT+port forwarding. 我在某些地方读到说VMware支持桥接,而VirtualBox支持NAT +端口转发。 I am quite confused as it is certain not the case in my situation.
我很困惑,因为可以肯定我的情况并非如此。 Maybe I am wrong.
也许我错了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.