我以前在Mac上使用Homebrew安装了Postgresql。
当我尝试访问数据库时,不断出现以下错误:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
与从psql
得到的错误消息相比,有没有办法得到更好的错误消息?
答案 0 :(得分:1)
是的
不幸的是,当Homebrew服务启动时,它可能会在无意识的情况下静默失败。
要确认您也是这种情况,请运行:
brew services list
您应该看到Postgresql的状态为started
。但是,颜色是黄色,而不是绿色(根据您的配色方案可能很难看到)。
黄色表示;实际状态是 unknown
而不是started
!
要从unknown
状态中获取含义,请使用pg_ctl
启动Postgresql服务器:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
此命令应输出实际问题:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
Referenced from: /usr/local/Cellar/postgresql/10.6_1/bin/postgres
Reason: image not found
no data was returned by command ""/usr/local/Cellar/postgresql/10.6_1/bin/postgres" -V"
The program "postgres" is needed by pg_ctl but was not found in the
same directory as "/usr/local/Cellar/postgresql/10.6_1/bin/pg_ctl".
Check your installation.
对于上面的示例,problem是icu4c
lib的版本。