Apple MacBook Pro M1 芯片 + Postgres + Connection refused 错误

Apple MacBook Pro M1 chip + Postgres + Connection refused error

我的 MacBook Pro M1 芯片出现以下错误

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?

在 MacBook Air 中,我曾经通过从 /usr/local/var/postgres/postmaster.pid 目录中删除 postmater.pid 来解决此错误。

但无法在 MacBook Pro M1 BigSur 中找到此 pid OS

在 MacBook Pro M1 芯片中,您可以在以下目录中找到 postmater.pid。

/System/Volumes/Update/mnt1/opt/homebrew/var/postgres/postmaster.pid

我已将其删除并重新启动 Postgres。现在一切都运行完美了。

在我的带 M1 的 Mac Mini 上,postmaster.pid 在这里: /System/Volumes/data/opt/homebrew/var/postgres

/System/Volumes/data/opt/homebrew/var/ 有效 请记住,如果您安装了不同的版本,它可能会有不同的标记,例如:/System/Volumes/data/opt/homebrew/var/postgres@12

我亲身遇到过很多次。因此,最好在 shell 中创建一个别名,以便再次轻松删除它 使用 zshrc:

alias psk='rm /System/Volumes/data/opt/homebrew/var/postgres/postmaster.pid'