我的mac锁定了所以我不得不做一个硬关机(按住电源键直到它关闭,然后重新打开)。现在,当我尝试启动我的本地rails应用程序(在崩溃之前运行正常)时,我得到以下Action Controller异常:
PG::ConnectionBad
could not connect to server: No such file or directory Is the server
running locally and accepting connections on Unix domain socket
"/var/pgsql_socket/.s.PGSQL.5432"?
一个月前,当我的计算机崩溃时,我遇到了类似的问题,最终我找到了解决方案。但是我今天一直在寻找和研究几个小时但没有运气。
我几乎是一个菜鸟但是为了它的价值,我用foreman start
启动服务器并使用Redis。但说实话,我不知道究竟是做什么的。
谢谢。
这通常对我有用。
$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
$ pg_ctl restart -D /usr/local/var/postgres
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
最终我最终卸载并重新安装postgresql:
brew remove postgresql
brew install postgresql
也许有一个不那么激烈的解决方案,但它非常快速和轻松,我重新开始营业。
我正在开发环境中工作,并准备丢失我的数据并重新设置我的数据库,但所有数据仍然存在。
PostgreSQL的数据目录中有一个文件,它存储了名为的PostgreSQL服务器的进程ID:
"postmaster.皮带"
如果系统崩溃,此文件仍可能指向旧进程或文件可能已损坏。可以通过删除文件并启动PostgreSQL服务器来解决此问题。
在Mac中,该文件位于:
/usr/local/var/postgresql@[version of postgresql]
e.g. /usr/local/var/[email protected]
Mac中PostgreSQL版本9.6的命令摘要:
cd /usr/local/var/[email protected]$
mv postmaster.pid postmaster.pid.bk
brew services start [email protected]