最近升级到 OSX Mavericks 后,我的 Rails 应用程序的数据库连接中断。
当我尝试从数据库中获取时,服务器返回以下错误:
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?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
当尝试运行时,psql
我得到:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
我已经尝试了许多互联网上可用的解决方案。这样重新安装 pg gem 并在我的 database.yml 中设置主机:localhost。我的 /usr/local/var/postgres/pg_hba.conf 文件说:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication RyanKing trust
#host replication RyanKing 127.0.0.1/32 trust
#host replication RyanKing ::1/128 trust
其中 psql 返回:/usr/local/bin/psql
这个有什么解决方案吗?一些解决方案建议我需要将我的 $PATH 更改为我以前的 postgres 安装,因为新版本的 postgres 将与 Mavericks 一起添加。我如何找到它的位置?它很可能是用自制软件安装的,但我不确定。