我已经在~/Library/LaunchAgents中创建了到/usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist的软链接。
如果我尝试手动加载postgres,我会收到“操作正在进行中”的消息。
> launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
/usr/local/Cellar/postgresql/9.4.0/homebrew.mxcl.postgresql.plist: Operation already in progress
然而,Postgres似乎没有在运行。
> ps auxw | grep post
billmcn 670 0.0 0.0 2424272 452 s000 R+ 10:12PM 0:00.01 grep post
我无法使用命令行客户端连接。
> 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"?
据我所知,我尝试了other Stackoverflow上讨论此问题的所有建议解决方法。具体来说:
- 我已卸载并重新安装了postgres和相应的Ruby gem。我的机器上没有postgres 8.0版本。
- 我已验证psql客户端程序是Homebrew安装的9.4.0版本,而不是Mac系统二进制文件。
- 我已验证/usr/local/var/postgres/postmaster.pid不存在。
- 我已重启了机器。
我之前在这台机器上成功使用过Homebrew postgres。我认为导致它出现问题的原因是从版本8升级到版本9,但我不确定。
我没有需要保留的数据库。我愿意用干净的postgres开始;我现在只需要让它工作。有什么想法吗?
这个问题似乎是由于 /usr/local/var/postgres 目录权限不正确所致。以下是在出现问题时我的 var 目录的情况。
ll /usr/local/var/
drwxr-xr-x 3 billmcn admin 102 Dec 20 12:44 cache
drwxr--r-- 2 root admin 68 Dec 29 21:37 postgres
(whoami = "billmcn")
我是"billmcn"。
我删除了 /usr/local/var/postgres,卸载并重新安装了 postgres,现在它看起来像这样。
ll /usr/local/var/
drwxr-xr-x 3 billmcn admin 102 Dec 20 12:44 cache
drwx------ 23 billmcn admin 782 Dec 30 10:51 postgres
我不确定它是如何进入这种状态的,因为我不记得在此目录上调整权限,但无论如何,现在它可以正常工作了。
whoami
/usr/local/var/postgres,然后运行initdb。 - Suge