0

可能重复:
Unix 域套接字“/var/pgsql_socket/.s.PGSQL.5432”上的 PostgreSQL 权限被拒绝错误 - Lion Server 10.7.3 或 Lion Server 10.7.4

我使用 postgres 作为 Rails 的后端数据库,但由于配置错误问题,它已停止工作,但我看不到它是什么。

我的 postgres 版本是 9.1.4,安装在 /usr/bin

我正在运行 ruby​​ 版本 1.9.3,但我必须在 rvm 中手动切换到它,因为会出现默认的 1.8.7。

我正在运行 Rails 3.2.8

我的配置文件 pg_hba.conf 看起来像:

# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

postgres.conf 文件中的大多数行都被注释掉了,除了一些无害的行,例如:

log_destination = 'stderr'
listen_addresses = '*'   
port = 5432                             
max_connections = 100                  

我还为 Mac 安装了“Postgres 应用程序”(请参阅​​ postgresapp.com/documentation),它说它正在运行并在端口 5432 上侦听。

当我运行 ps -ax | 我看到的 grep 帖子:

1088 ??         0:00.08 com.heroku.postgres-service
 1135 ??         0:00.29 /Applications/Postgres.app/Contents/MacOS/bin/postgres -D /Users/rickc/Library/Application Support/Postgres/var -p5432
 1137 ??         0:01.14 postgres: writer process      
 1138 ??         0:00.78 postgres: wal writer process      
 1139 ??         0:00.20 postgres: autovacuum launcher process      
 1140 ??         0:00.26 postgres: stats collector process      

但是当我尝试在 localhost:3000 启动 rails connect 时,我收到以下错误消息:PG::Error

could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

我试图在这里检查以前的帖子,当然,postgres 文档看不到这里配置错误的地方;非常感谢任何帮助...

4

1 回答 1

-1

这是一个 postgres 问题,而不是 rails/ruby 问题。

为了向自己证明这一点,请打开一个终端并执行

psql -U username -W db_name

username您的用户名在哪里,db_name是数据库的名称。

您应该收到“无法连接到服务器”错误。

这是你要做的:

  • tail您的 postgres 在终端窗口中登录
  • 重启 postgres 并观察终端

您将在日志中看到问题。如果您无法找出问题所在,请发布日志的相关部分,我们将进行查看。

于 2012-11-27T21:18:57.407 回答