无法通过brew services连接运行的Postgres服务器。
无法通过brew services连接运行的Postgres服务器。
我一直在寻找解决这个问题的方法,但没有找到有效的解决方案。
我在我的Macbook上使用brew(brew install postgres
)安装了postgres,并且正在使用brew services运行它(brew services list
显示postgres作为运行中的服务)。然而,当我尝试运行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\"?
有人已经解决了类似的问题吗?
admin 更改状态以发布 2023年5月24日
我遇到了同样的错误,我通过删除进程pid文件来解决它:
rm -f /usr/local/var/postgres/postmaster.pid
或者针对特定版本:
rm -f /usr/local/var/postgresql@14/postmaster.pid
[针对基于Arm芯片的电脑(Apple M1)的更新答案]
在Apple M1电脑上使用brew
安装postgresql
时,postmaster.pid
将位于:
/opt/homebrew/var/postgresql/postmaster.pid
按照以下三个步骤:
# 1. Stop PostgreSQL brew services stop postgresql # 2. Delete the postmaster.pid rm -f /opt/homebrew/var/postgresql@12/postmaster.pid # 3. Start the PostgreSQL again brew services start postgresql
上述操作后,您还可以通过brew services info postgresql
检查服务状态
brew services info postgresql postgresql@12 (homebrew.mxcl.postgresql) Running: Loaded: Schedulable: ✘ User: root PID: 34884