tim*_*xyz 5 postgresql macos psql
当我尝试通过webapp访问postgres,或打开postgres shell时psql -d template1
,我收到错误.
psql:无法连接到服务器:没有这样的文件或目录服务器是否在本地运行并接受Unix域套接字"/tmp/.s.PGSQL.5432"上的连接?
(*我已经阅读了很多有关此错误的SO主题,但推荐的解决方案并未解决此问题)
将postgres作为服务启动:
brew services restart postgresql
Run Code Online (Sandbox Code Playgroud)
停止
postgresql
...(可能需要一段时间)==>已成功停止postgresql
(标签:homebrew.mxcl.postgresql)==>已成功启动postgresql
(标签:homebrew.mxcl.postgresql)
在终端中手动运行postgres:
我可以通过在终端窗口中运行来完成所有工作,但我更喜欢在后台运行它.
postgres -D /usr/local/var/postgres9.6.3
Run Code Online (Sandbox Code Playgroud)
集群:
我有3个数据库集群/usr/local/var
,但我想使用postgres9.6.3/
postgres
postgres9.5/
postgres9.6.3/
Run Code Online (Sandbox Code Playgroud)
哪一个:
which psql
回报 /usr/local/bin/psql
路径:
echo $PATH
返回/usr/local/bin
并/usr/local/var
(添加)
其他推荐解决方案
很多人能够通过删除a来修复此问题/postgres/postmaster.pid
,但此文件对我来说并不存在.
ps -ef | grep postgres
仅运行,输出,
501 2135 1530 0 12:08pm ttys002 0:00.00 grep postgres
Run Code Online (Sandbox Code Playgroud)
重启postgres后brew servies
,postgres.log
在/usr/local/var/log
contains中,
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.
Run Code Online (Sandbox Code Playgroud)