我在Windows 7中安装了PostgreSQL 9.2,在虚拟机中安装了Windows XP,如何连接这两个数据库并允许远程访问从两个系统添加/编辑数据库?
我在Windows 7中安装了PostgreSQL 9.2,在虚拟机中安装了Windows XP,如何连接这两个数据库并允许远程访问从两个系统添加/编辑数据库?
要远程访问PostgreSQL数据库,必须设置两个主要的PostgreSQL配置文件:
postgresql.conf
以下是有关如何设置这些参数的简要说明(请注意,以下说明仅用于说明:要安全配置机器,必须熟悉所有参数及其含义)
首先,将PostgreSQL服务配置为在Windows 7计算机的所有网络接口上的端口5432上侦听:
listen_addresses = '*'
判断WindowsXP虚拟机的网络地址,并在pg_hba中设置参数.conf文件(位于postgresql.conf的同一目录中),以便postgresql可以接受来自虚拟机主机的连接
host all all 192.168.56.1/24 md5
这样,PostgreSQL将接受来自网络192.168.1上所有主机的连接.XXX.
Restart the PostgreSQL service in Windows 7 (Services-> PosgreSQL 9.2: right click and restart sevice). Install pgAdmin on windows XP machine and try to connect to PostgreSQL.