Postgresql服务器正在本地运行,但psql无法连接。

29 浏览
0 Comments

Postgresql服务器正在本地运行,但psql无法连接。

在执行 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?

admin 更改状态以发布 2023年5月25日
0
0 Comments

来自 a_horse_with_no_name 的链接对我有帮助。具体来说:

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

(来自Homebrew postgres broken)

然后

 createdb 

(后者来自psql: FATAL: database""does not exist)

0