我安装了PostgreSQL并尝试连接:
$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
$ ps aux | grep postg
$ sudo service postgresql start
-不会产生结果。
$ psql -U ivan -h localhost msg_proxy
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
为什么?我的iptables似乎正常:
$ sudo iptables-save
# Generated by iptables-save v1.6.0 on Mon Feb 6 13:31:17 2017
*filter
:INPUT ACCEPT [43867:5867960]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [34820:18177695]
COMMIT
# Completed on Mon Feb 6 13:31:17 2017
sudo netstat -pant | grep postgres
的输出为空
1条答案
按热度按时间fquxozlt1#
回应这个老问题可能不是最好的主意,因为这个问题有一些信息,比如:
如输出所示,要么PostgeSQL没有运行,要么不接受连接:
1.如果在你的进程中看不到PostgreSQL,你确定PostgreSQL在那里吗?
辅助系统|grep postgres
1.如果PostgreSQL位于同一网络中的另一台服务器,请尝试以下操作:
psql -h数据库地址-d数据库名称-U用户名-W