我正在尝试从pgAdmin III连接到远程数据库.我创建了" 新服务器注册 ".当我连接到数据库时,我得到"访问数据库被拒绝".
我设置正确.这些是我的PostgreSQL设置:
pg_hba.conf >
PostgreSQL客户端身份验证配置文件
# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all postgres trust local all all md5 # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. host all all 192.168.0.0/16 md5
postgresql.conf >我允许所有的连接listen_addresses = '*'
使用SSH我可以连接到数据库:
[fuiba@test]$ psql -h localhost -p 26888 -d postgres psql (9.1.11) Type "help" for help. postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges --------------+---------+----------+---------+-------+--------------------- postgres | fuiba | UTF8 | C | C | template0 | fuiba | UTF8 | C | C | =c/fuiba + | | | | | fuiba=CTc/fuiba template1 | fuiba | UTF8 | C | C | =c/fuiba + | | | | | fuiba=CTc/fuiba (3 rows)
我究竟做错了什么?任何帮助将受到高度赞赏.谢谢!
ps:我在Windows 7上运行pgAdmin III,在Linux CentOS上运行PostgreSQL.
与通过SSH登录到数据库服务器时相比,pgAdmin从其他主机连接到PostgreSQL.您的错误消息中没有提到错误消息中提到的IP地址(以93.39开头)pg_hba.conf
.
将运行pgAdmin的主机的公共IP地址(以93.39开头的地址)添加到pg_hba.conf
SSH隧道或通过SSH隧道连接.注意重新加载PostgreSQL的配置或修改后重启PostgreSQL pg_hba.conf
.