Ubuntu下访问Windows中Postgresql

  因为项目的原因,需要将Ubuntu中的一些信息记录到Windows中的Postgresql数据库中,查看网上信息,最后成功了,特地记录以下,需要以下步骤:

(1)在Windows中Postgresql目录下找到pg_hba.conf文件,并做修改。

  在此文件中添加一行,格式参考下面七种:

local database user auth-method [auth-option]

host database user CIDR-address auth-method [auth-option]

hostssl database user CIDR-address auth-method [auth-option]

hostnossl database user CIDR-address auth-method [auth-option]

host database user IP-address IP-mask auth-method [auth-option]

hostssl database user IP-address IP-mask auth-method [auth-option]

hostnossl database user IP-address IP-mask auth-method [auth-option]

  如host all all 192.168.1.0/24 md5,表示允许网段192.168.1.0上的所有主机使用所有合法的数据库用户名访问数据库,并提供加密的密码验证

(2)在Windows中Postgresql目录下找到postgresql.conf文件,修改postgresql.conf文件,将数据库服务器的监听模式修改为监听所有主机发出的连接请求。

  将文件中listen_addresses=’localhost’更改为listen_addresses=’*‘

  

  做完以上两步,重启数据库服务,检查是否能够正常访问,不行的话检查防火墙设置。

(3)在Windows防火墙页面,选择左侧高级设置,添加规则。

转载于:https://www.cnblogs.com/HelloMoying/p/6421827.html

  因为项目的原因,需要将Ubuntu中的一些信息记录到Windows中的Postgresql数据库中,查看网上信息,最后成功了,特地记录以下,需要以下步骤:

(1)在Windows中Postgresql目录下找到pg_hba.conf文件,并做修改。

  在此文件中添加一行,格式参考下面七种:

local database user auth-method [auth-option]

host database user CIDR-address auth-method [auth-option]

hostssl database user CIDR-address auth-method [auth-option]

hostnossl database user CIDR-address auth-method [auth-option]

host database user IP-address IP-mask auth-method [auth-option]

hostssl database user IP-address IP-mask auth-method [auth-option]

hostnossl database user IP-address IP-mask auth-method [auth-option]

  如host all all 192.168.1.0/24 md5,表示允许网段192.168.1.0上的所有主机使用所有合法的数据库用户名访问数据库,并提供加密的密码验证

(2)在Windows中Postgresql目录下找到postgresql.conf文件,修改postgresql.conf文件,将数据库服务器的监听模式修改为监听所有主机发出的连接请求。

  将文件中listen_addresses=’localhost’更改为listen_addresses=’*‘

  

  做完以上两步,重启数据库服务,检查是否能够正常访问,不行的话检查防火墙设置。

(3)在Windows防火墙页面,选择左侧高级设置,添加规则。