Unix 域套接字上的 Postgres 连接“/tmp/.s.PGSQL.5432”?

Dev*_*anu 5 postgresql macos homebrew

我正在运行 MacOS 10.14.1(MacOS 的新手),我无法运行psql通过 安装的命令brew,我收到以下错误,希望得到一些帮助:

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)

我尝试过的解决方案

  1. brew services start 服务已经在运行
  2. brew services stop postgresql, brew services start postgresql 还是一样的错误
  3. brew remove postgres, brew install postgres, psql 还是一样的错误
  4. brew unlink postgresql && brew link postgresql 还是一样的错误
  5. rm -f /usr/local/var/postgres/postmaster.pid我的/usr/local/var/不包含postgres/文件夹

还有一件事要注意,当brew install postgres我收到警告时:

Warning: The post-install step did not complete successfully
You can try again using `brew postinstall postgresql`
Run Code Online (Sandbox Code Playgroud)

运行brew postinstall postgresql给出相同的警告。

希望提供足够的信息,很高兴提供更多信息。

Pri*_*ike 0

尝试这个

initdb /usr/local/var/postgres
Run Code Online (Sandbox Code Playgroud)