Unable to connect to postgresql database after upgrading to Yosemite 10.10

扶醉桌前 提交于 2019-12-20 11:55:53

问题


After updating to Yosemite 10.10 I cannot connect to my postgresql database. I run the rails console and try and get the first user but get this error...

>     ➜  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)>

What do I do! I have tried to reinstall postgresql, reinstall homebrew. Please help!


回答1:


You are better off using the easy method by installing the http://postgresapp.com/ app! I too had this same issue with 10.9.4. Also with 10.10.

brew install postgres will give issues when doing any OS X upgrades so avoid it. So install the app then:

Add this to your profile if the install do not work out of the box. For me I never had to add the below in my profile:

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

This line must be at the top of your profile:

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

Good luck!




回答2:


I found this.

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

It worked for me.




回答3:


Checking the server.log will show you what directories it's looking for. Adding them to your postgres directory should fix this. (Was going to comment above, but don't have enough reputation)



来源:https://stackoverflow.com/questions/26447736/unable-to-connect-to-postgresql-database-after-upgrading-to-yosemite-10-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!