簡體   English   中英

為什么psql無法連接到服務器?

[英]Why psql could not connect to server?

我以前在帶有Homebrew的Mac上安裝了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得到的錯誤消息相比,有沒有辦法得到更好的錯誤消息?

是。

不幸的是,當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.

對於上面的示例, 問題icu4c lib的版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM