Ruby-on-rails 在 MAC OS X 上拒绝 Postgres 权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10791904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 03:27:50  来源:igfitidea点击:

Postgres permission denied on MAC OS X

ruby-on-railsruby-on-rails-3macospostgresqlosx-lion

提问by Andre Cytryn

I was following the ruby on rails tutorial to run with postgres but when I try the "rake db:create" I get the following error:

我正在关注 ruby​​ on rails 教程以使用 postgres 运行,但是当我尝试“rake db:create”时,出现以下错误:

could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

I have found this question issuing some similar problem but I couldnt make it work anyway.

我发现这个问题发出了一些类似的问题,但无论如何我都无法让它工作。

Repairing Postgresql after upgrading to OSX 10.7 Lion

升级到 OSX 10.7 Lion 后修复 Postgresql

I have installed homebrew after reading this question and the path is fine, brew doctor shows me no errors on path.

阅读此问题后,我安装了自制软件,路径很好,brew doctor 显示路径上没有错误。

回答by Jared Beck

Instead of troubleshooting your socket filepermissions, you could try a TCP connection. Add host: localhostto your config/database.yml. Of course, this will only work if postgres is listening for TCP traffic. Postgres listens on port 5432 by default, so netstat -an | grep 5432will tell you if it is listening.

您可以尝试TCP 连接,而不是对套接字文件权限进行故障排除。添加到您的. 当然,这只有在 postgres 正在侦听 TCP 流量时才有效。Postgres 默认侦听端口 5432,因此会告诉您它是否正在侦听。host: localhostconfig/database.ymlnetstat -an | grep 5432

References

参考

回答by duykhoa

Oh, may be you are open postgre in another application, like pgadminhttp://www.pgadmin.org/Try to close any application that use postgre SQL and run your command again.

哦,可能是您在另一个应用程序中打开了 postgre,例如pgadmin http://www.pgadmin.org/尝试关闭任何使用 postgre SQL 的应用程序并再次运行您的命令。

回答by Jillian Hoenig

I had the same issue. After unsuccessfully trying all the suggestions posted above, I finally quit out of terminal and restarted it.

我遇到过同样的问题。在尝试了上面发布的所有建议失败后,我终于退出了终端并重新启动了它。

This worked.

这奏效了。

回答by Zender

Just check if your config/database.yml has------host: localhost and port: (check for yourself by netstat -an | grep 5432 or 5433)

只需检查您的 config/database.yml 是否具有------主机:本地主机和端口:(通过 netstat -an | grep 5432 或 5433 自行检查)

回答by Patrik Affentranger

I ran into the same problem today and found this blog post below which helped me:

我今天遇到了同样的问题,并在下面找到了这篇博客文章,它对我有帮助:

http://nextmarvel.net/blog/2011/09/brew-install-postgresql-on-os-x-lion/

http://nextmarvel.net/blog/2011/09/brew-install-postgresql-on-os-x-lion/

It moves your OS X default postgres binaries into an archive folder and symlinks the homebrew versions in place of them.

它将您的 OS X 默认 postgres 二进制文件移动到一个存档文件夹中,并用符号链接自制软件版本来代替它们。

TL;DRcurl http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh | sh

TL; 博士curl http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh | sh

回答by Eric Norcross

I also ran into this problem because I had both the mysql and pg gems active in my Gemfile.

我也遇到了这个问题,因为我的 Gemfile 中同时激活了 mysql 和 pg gem。

I commented out the mysql gem:

我注释掉了 mysql gem:

# mysql 

Then ran:

然后跑:

bundle install 

and then:

进而:

rake db:migrate 

and it worked like a charm.

它就像一个魅力。