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的一个伟大的包装。

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...