当我尝试通过webapp访问postgres,或者使用psql -d template1
打开postgres shell时,出现错误。为什么在将它作为服务运行时不能访问postgres?
PSQL:无法连接到服务器:没有这样的文件或目录的 服务器本地运行和验收Unix域连接 插座“/tmp/.s.PGSQL.5432”?
(*我读过一些关于这个错误的SO线程,但建议的解决方案并没有解决这个问题对我来说)
开始的Postgres即服务:
brew services restart postgresql
停止
postgresql
...(可能需要一段时间) ==>已成功停止postgresql
(标签:homebrew.mxcl.postgresql) ==>成功星标泰德postgresql
(标签:homebrew.mxcl.postgresql)
手动在终端上运行的Postgres:
我可以搞定一切通过在终端窗口中运行以下的工作,但我宁愿跑它在后台。
postgres -D /usr/local/var/postgres9.6.3
集群:
我有3分贝集群/usr/local/var
,但我想用postgres9.6.3/
postgres
postgres9.5/
postgres9.6.3/
其中:
which psql
回报/usr/local/bin/psql
路径:
echo $PATH
回报/usr/local/bin
和/usr/local/var
(添加)
其他推荐的解决方案:
很多人在那里能够通过去除/postgres/postmaster.pid
解决这个问题,但这文件对我来说不存在。
UPDATE
运行ps -ef | grep postgres
,仅输出,
501 2135 1530 0 12:08pm ttys002 0:00.00 grep postgres
与brew servies
重启的Postgres后,postgres.log
在/usr/local/var/log
包含,
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.3.
感冒副本| grep postgres'显示什么?如果没有,服务器实际上并没有运行 - 看起来很可能,鉴于错误。检查日志(应该在/usr/local/var/log/postgres.log中),看看有没有什么有趣的地方。 – dmfay
添加了对问题 –