升级到Yosemite 10.10后,无法连接到postgresql数据库



更新到Yosemite 10.10后,我无法连接到我的postgresql数据库。我运行rails控制台并尝试获取第一个用户,但出现了这个错误。。。

>     ➜  game_golf git:(master) ✗ rails c
>     Loading development environment (Rails 4.1.4)
>     [1] pry(main)> User.first
>     PG::ConnectionBad: 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" (127.0.0.1) and accepting
>       TCP/IP connections on port 5432?
>     from /Users/pauldornfeld/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
>     [2] pry(main)>

我该怎么办!我试着重新安装postgresql,重新安装自制程序。请帮忙!

我发现了这个。

cd /usr/local/var/postgres
mkdir pg_tblspc pg_twophase pg_stat_tmp

它对我有效。

检查server.log将显示它正在查找的目录。将它们添加到postgres目录应该可以解决这个问题。(本想在上面发表评论,但没有足够的声誉)

您最好使用简单的方法,安装http://postgresapp.com/应用程序!我在10.9.4时也遇到了同样的问题。还有10.10。

brew install postgres在进行任何OS X升级时都会出现问题,因此请避免。因此,请安装应用程序:

如果安装无法开箱即用,请将其添加到您的配置文件中。对我来说,我从未在我的个人资料中添加过以下内容:

export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

这一行必须在您的个人资料的顶部:

export PATH=/usr/local/bin:$PATH

祝你好运!

最新更新