首页 文章

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

提问于
浏览
29

更新到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,重新安装自制程序 . 请帮忙!

3 回答

  • 9

    最好通过安装http://postgresapp.com/ app来使用easy方法! 10.9.4我也有同样的问题 . 还有10.10 .

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

    如果安装不能立即使用,请将其添加到您的配置文件中 . 对我来说,我从来没有在我的 Profiles 中添加以下内容:

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

    此行必须位于 Profiles 的顶部:

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

    祝好运!

  • 99

    我找到this .

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

    它对我有用 .

  • -5

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

相关问题