【问题标题】:Postgresql server is running on local machine but psql can not connectPostgresql 服务器正在本地机器上运行,但 psql 无法连接
【发布时间】:2017-11-23 13:43:57
【问题描述】:

做完brew install postgres:

brew install postgres
brew link --overwrite postgresql

Postgres 已经在运行:

/~ $brew services start postgresql
Service `postgresql` already started, use `brew services restart postgresql` to restart.

那么我们如何使用psql 客户端进行连接呢?

13:47:28/~ $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"?

更新尝试了各种建议。

尝试重新启动..

 $brew services start postgresql
Service `postgresql` already started, use `brew services restart postgresql` to restart.
14:37:19/fastparquet $brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)

14:37:39/fastparquet $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"?
14:37:55/fastparquet $

连接到本地主机?

14:37:34/fastparquet $psql -h localhost
psql: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

【问题讨论】:

  • psql -h localhost 工作吗?
  • 另请参阅:stackoverflow.com/q/27700596/330315stackoverflow.com/a/17411832/330315,如果您确实确定 Postgres 确实在运行
  • Postgres 显然没有运行
  • @a_horse_with_no_name 。看起来那是当场的。请回答:您可以在 OP 中使用我的 update 了解更多详情
  • 您可以回答自己的问题(并接受该答案)。它没有任何问题。

标签: postgresql


【解决方案1】:

a_horse_with_no_name 的链接起到了作用。具体来说:

initdb -D /usr/local/var/postgres/

(来自Homebrew postgres broken

然后

 createdb 

(后者来自psql: FATAL: database "<user>" does not exist

【讨论】:

    猜你喜欢
    • 2019-03-21
    • 1970-01-01
    • 2015-07-29
    • 1970-01-01
    • 2013-05-19
    • 2015-10-17
    • 2015-08-15
    • 2018-06-22
    • 2014-10-22
    相关资源
    最近更新 更多