从Win7连接到Linux VirtualBox中的PostgreSql数据库 [英] Connect to PostgreSql database in Linux VirtualBox from Win7

查看:210
本文介绍了从Win7连接到Linux VirtualBox中的PostgreSql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题中所述,我正在尝试从Win7主机访问Linux Centos 5.8中建立的Postgres 9.3,后者在同一台计算机上的VirtualBox中.我正在尝试从PGAdmin访问它,并且当我从Win7服务启动Postgre时一切正常,因此PGAdmin配置正确.

As said in headline, from Win7 host I'm trying to access Postgres 9.3 established in Linux Centos 5.8 which is in VirtualBox on the same machine. I'm trying to access it from PGAdmin and everything is OK when I start the Postgre from Win7 services, so PGAdmin is well configured.

我尝试了什么?我已经阅读了许多有关此主题的文章,甚至在该论坛上也遇到了一些问题,但没有任何效果.我有:

What have I tried? I've read many articles about this subject, and even some questions on this forum but nothing worked. I have:

  1. 切换到NAT并在VirtualBox GUI中转发端口5432
  2. 在postgresql.conf文件中
  3. set listenadresses ='*'
  4. 将pg_hba.conf文件中的所有10.0.2.1/24 md5行全部托管
  5. 在win7防火墙设置中输入5432端口入站和出站规则
  6. 已禁用#service iptables stop的linux防火墙
  1. switched to NAT and forwarded port 5432 in VirtualBox GUI
  2. set listenadresses = '*' in postgresql.conf file
  3. put host all all 10.0.2.1/24 md5 line in the pg_hba.conf file
  4. put 5432 port inbound and outbound rule in win7 firewall settings
  5. disabled linux firewall with #service iptables stop

仅此而已.在虚拟linux中启动服务时,我可以从linux访问它,因此可以正确启动服务.问题是Windows无法看到该服务.从Linux启动服务时,尽管应该占用端口5432,但我可以在Win中启动相同的服务,反之亦然.

Just to mention. When service is started in virtual linux, I can access it from linux, so service is properly started. Problem is that windows doesn't see that service. And when service is started from linux, I can start the same service in Win and vice-versa although the port 5432 should be occupied.

对我来说,最可疑的部分是第3点),因为我不确定我是否在规则上打了好字.该地址因文章而异,根据我的网络,如果有人可以向我解释如何确定要在其中放置哪个地址(或范围),我将不胜感激.或其他一些建议(如果可能).谢谢.

The most suspicious part to me is point 3) because I'm not sure whether i have put good address in rule. That address vary from article to article, and I would appreciate if someone could explain me how to be sure which address (or range) to put there, according to my network. Or some other advice if possible. Thanks.

推荐答案

已解决.

替换:

全部托管所有10.0.2.1/24 md5"和全部托管所有0.0.0.0/0信任"解决了该问题.

"host all all 10.0.2.1/24 md5" with "host all all 0.0.0.0/0 trust" solved it.

这篇关于从Win7连接到Linux VirtualBox中的PostgreSql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆