window下链接liunx下面的PostgreSQL

因为搭建了一个虚拟机,因此想找windows下面链接虚拟机下面的pg数据库,下载好链接工具以后发现怎么都不通。 在window下面的命令行用telnet 192.168.234.128 5432,提示端口不通。 在liunx下面开放端口访问: 查看端口是否已经开放 /etc/init.d/iptables status 输入图片说明sql

没有就须要开放端口访问 #开启5432端口 /sbin/iptables -I INPUT -p tcp --dport 5432 -j ACCEPT #保存配置 /etc/rc.d/init.d/iptables save #重启服务 /etc/rc.d/init.d/iptables restart数据库

自后须要配置liunx下面pg的配置文件,只须要修改data目录下的pg_hba.conf和postgresql.conf pg_hba.conf:配置对数据库的访问权限。 postgresql.conf:配置PostgreSQL数据库服务器的相应的参数。 1.修改pg_hba.conf文件: 在# IPv4 local connections下面增长一行,有两种配置,一个须要密码登录,不须要密码登录:windows

host all all 0.0.0.0/0 md5(须要密码登录)服务器

host all all 0.0.0.0/0 trust(不须要密码登录)tcp

2.修改postgresql.conf文件 listen_addresses = '*' port = 5432工具

以后从新启动pg数据库就好post

注意: 虽然liunx的pg用户和liunx下面用户的用户名同样,可是登录到pg以后,这个用户其实没密码,若是须要设置密码,能够在登录以后,能够用命令修改密码: ALTER USER postgres WITH PASSWORD 'a123456';命令行

也能够新建用户: CREATE USER postgres PASSWORD 'a123456';rest

相关文章
相关标签/搜索