微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PostgreSQL错误“无法连接到服务器:没有这样的文件或目录”

像其他人,我得到这个错误时,我运行rake db:migrate在我的项目,甚至尝试大多数数据库任务我的 Ruby on Rails 3.2应用程序。

PGError (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”?

很久以前,我安装PostgreSQLHomebrew,并尝试安装MongoDB最近我的Postgresql安装从来没有过相同。我运行的是OS X v10.6 SNow Leopard。

有什么问题,我如何更好地了解Postgresql是如何和应该在我的Mac上设置?

到目前为止(我想)这告诉我Postgresql没有运行(?)。

ps -aef|grep postgres                                                                                                   (ruby-1.9.2-p320@jct-ana) (develop) ✗
  501 17604 11329   0   0:00.00 ttys001    0:00.00 grep postgres

但是这是否告诉我Postgresql正在运行?

✪ launchctl load -w /usr/local/Cellar/postgresql/9.1.4/homebrew.mxcl.postgresql.plist                                                        (ruby-1.9.2-p136) 
homebrew.mxcl.postgresql: Already loaded

我该如何解决?我没有看到什么?

PS:〜/ Library / LaunchAgents包含两个Postgresql .plist文件。我不知道这是否相关。

org.postgresql.postgres.plist
homebrew.mxcl.postgresql.plist

我试过下面的结果如下。

$ psql -p 5432 -h localhost

psql: 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?
Could not connect to server: Connection refused
    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" (fe80::1) and accepting
    TCP/IP connections on port 5432?

我读过,因为这是发生,因为OS X安装自己的版本的Postgresql和Homebrew安装不同的版本在不同的地方,Postgresql命令在/ tmp /目录中查找。你需要搜索更多的Stack Overflow,但基本上你符号链接Postgresql,以便任何东西在tmp路径实际找到真正的路径,如果这是有道理的。

这是链接,我发现了几个更多的东西,特别是做上面的符号链接Mac OSX Lion Postgres does not accept connections on /tmp/.s.PGSQL.5432.我仍然希望有人会把一个正确的解释在OS X上安装Postgresql的概念,为什么它是如此困难。

最新见解,有助于排查问题:

$ which psql // This tells you which Postgresql you are using when you run $ psql.

然后运行:

$ echo $PATH

要考虑的关键是:

确保Postgresql副本的路径条目要在OS X系统的Postgresql的路径之前运行COMES。

这是一个核心要求,决定哪些Postgresql运行,是我被告知导致大多数这些问题。

检查在你的postgres目录中没有postmaster.pid,可能是/usr/local/var / postgres /

删除此和启动服务器。

检查 – https://github.com/mperham/lunchy是launchctl的一个伟大的包装。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐