简体   繁体   English

MAC OS X上的Postgres权限被拒绝

[英]Postgres permission denied on MAC OS X

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医生告诉我路径上没有错误。

Instead of troubleshooting your socket file permissions, you could try a TCP connection . 您可以尝试TCP连接 ,而不是排除套接字文件权限。 Add host: localhost to your config/database.yml . host: localhost添加到config/database.yml Of course, this will only work if postgres is listening for TCP traffic. 当然,这只有在postgres正在侦听TCP流量时才有效。 Postgres listens on port 5432 by default, so netstat -an | grep 5432 Postgres默认侦听端口5432,所以netstat -an | grep 5432 netstat -an | grep 5432 will tell you if it is listening. netstat -an | grep 5432会告诉你它是否在听。

References 参考

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

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;DR curl http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh | sh TL; DR curl http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh | sh curl http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh | sh

I had the same issue. 我遇到过同样的问题。 After unsuccessfully trying all the suggestions posted above, I finally quit out of terminal and restarted it. 在尝试上面发布的所有建议失败后,我终于退出终端并重新启动它。

This worked. 这很有效。

只需检查你的config / database.yml是否有------ host:localhost和port :(由netstat -an | grep 5432或5433自行检查)

I also ran into this problem because I had both the mysql and pg gems active in my Gemfile. 我也遇到了这个问题,因为我的Gemfile中有mysql和pg gems都处于活动状态。

I commented out the mysql gem: 我注释掉了mysql gem:

# mysql 

Then ran: 然后跑了:

bundle install 

and then: 接着:

rake db:migrate 

and it worked like a charm. 它就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM