升级到 OSX 10.7 Lion 后修复 Postgresql [英] Repairing Postgresql after upgrading to OSX 10.7 Lion

查看:29
本文介绍了升级到 OSX 10.7 Lion 后修复 Postgresql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到 OSX 10.7,此时我的 rails 安装在尝试连接到 psql 服务器时完全停止.当我使用

从命令行执行此操作时

psql -U postgres

它完全正常,但是当我尝试使用相同的用户名和密码运行 rails 服务器或控制台时,出现此错误

...activerecord-3.0.9/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `initialize': 无法连接到服务器: 权限被拒绝 (PGError)服务器是否在本地运行并接受Unix 域套接字/var/pgsql_socket/.s.PGSQL.5432"上的连接?

任何可能发生的事情都会非常有帮助!谢谢!

解决方案

这是一个 PATH 问题.Mac OSX Lion 现在在系统中包含 Postgresql.如果你执行 which psql 你可能会看到 usr/bin/psql 而不是 usr/local/bin/psql 这是 HomeBrew 的正确一.如果您运行 brew doctor,您应该收到一条消息,指出您需要将 usr/local/bin 添加到 PATH 环境变量的头部.

编辑您的 .bash_profile 或 .profile,或您使用的任何 shell 并添加:export PATH=/usr/local/bin:$PATH

作为 PATH 的第一个导出,然后退出 shell 会话或使用 source ~/.bash_profile 获取文件,现在应该又可以了.

I recently upgraded to OSX 10.7, at which point my rails installation completely borked when trying to connect to the psql server. When I do it from the command line using

psql -U postgres

it works totally fine, but when I try to run the rails server or console with the same username and password, I get this error

...activerecord-3.0.9/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `initialize': could not connect to server: Permission denied (PGError) 
Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

Any ideas what might be going on would be super helpful! Thanks!

解决方案

It's a PATH issue. Mac OSX Lion includes Postgresql in the system now. If you do a which psql you'll likely see usr/bin/psql instead of usr/local/bin/psql which is HomeBrew's correct one. If you run brew doctor you should get a message stating that you need to add usr/local/bin to the head of your PATH env variable.

Editing your .bash_profile or .profile, or whichever shell you're using and adding: export PATH=/usr/local/bin:$PATH

as the first export for the PATH then either quit you shell session or source your file with source ~/.bash_profile and it should now be OK again.

这篇关于升级到 OSX 10.7 Lion 后修复 Postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆