我有一个运行postgres的数据库服务器(192.168.1.50).我创建了一个名为"testdb"的数据库和一个密码为"testuserpw"的用户"testuser".
在本地,我可以使用以下命令连接到数据库:
psql -d testdb -U testuser
Run Code Online (Sandbox Code Playgroud)
当我从另一台主机(192.168.1.60)发出命令时:
psql -h 192.168.1.50 -d testdb -U testuser
Run Code Online (Sandbox Code Playgroud)
我有错误:
psql: could not connect to server: Connection refused
Is the server running on host "192.168.1.50" and accepting
TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?
ara*_*nid 49
检查的设置listen_addresses在你的postgresql.conf文件中.许多发行版使其默认为127.0.0.1,即只监听来自localhost的连接.它应设置为'*'侦听所有接口上的连接.
如果您仍然遇到问题,请使用lsof以查看postgres进程正在侦听的网络套接字.
在Ubuntu上,我注意到远程访问在某些时候停止工作(目前使用9.1.9).原因是,postgres不再使用-i开关[1]启动,因此无论您为listen_addresses配置什么,它都将被忽略.
幸运的是,添加以下行以/etc/environment在注销后再次(或重新引导)解决问题:
PGOPTIONS="-i"
Run Code Online (Sandbox Code Playgroud)
有关更多选项,请参见[2].请注意,添加此/etc/postgresql/9.1/main/environment内容对我来说不起作用.
现在,在做的时候nmap ip-of-my-remote-server我终于得到了这个:
5432/tcp open postgresql
Run Code Online (Sandbox Code Playgroud)
好极了!
[1] http://www.postgresql.org/docs/9.1/static/runtime-config-short.html
[2] http://www.postgresql.org/docs/9.1/static/libpq-envars.html
| 归档时间: |
|
| 查看次数: |
65676 次 |
| 最近记录: |