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

时间:2021-06-23 22:45:42

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...

更新到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)>

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

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

3 个解决方案

#1


-5  

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.

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

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

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

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


99  

I found this.

我找到了这个。

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

It worked for me.

它对我有用。

#3


9  

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)

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

#1


-5  

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.

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

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

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

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


99  

I found this.

我找到了这个。

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

It worked for me.

它对我有用。

#3


9  

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)

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