Homebrew/OSX可怕的"psql:无法连接到服务器:没有这样的文件"错误

Ric*_*ard 6 postgresql macos homebrew

我刚刚重新启动了OSX(Sierra 10.12.6),当我尝试运行时psql(以前工作正常)我得到了可怕的:

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"?
Run Code Online (Sandbox Code Playgroud)

尝试brew services restart postgresql没有帮助,并brew services start postgresql声称该服务已在运行.

然而,ps auxw | grep postgres没有发现Postgres进程正在运行.Homebrew有困惑吗?

which psql节目/usr/local/bin/psql.

这是我试过的......

psql -h localhost 没有区别.

brew uninstall --force postgresql跟着跑了brew install postgresql,这没什么区别.我也试过后做同样的brew doctorbrew update,这也没有什么区别.

我已经看到删除postmaster.pid文件的建议,但是没有这样的文件/usr/local/var/postgres/.server.log该目录中似乎也没有文件.

运行locate PGSQL.5432显示没有文件.

我是/usr/local/var/postgres目录的所有者,拥有drwxr-xr-x权限.

我可能在过去的某个时候安装了KyngChaos postgres.

我检查了brew services list(~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist)输出中指示的.plist文件,它显示如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>KeepAlive</key>
  <true/>
  <key>Label</key>
  <string>homebrew.mxcl.postgresql</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/postgresql/bin/postgres</string>
    <string>-D</string>
    <string>/usr/local/var/postgres</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/usr/local</string>
  <key>StandardErrorPath</key>
  <string>/usr/local/var/log/postgres.log</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

如果可能的话,我非常希望不必删除我所有的postgres数据库,因为我目前在一个偏远的地方无处支持它们!