我最近升级到ubuntu 11.10,每当我运行我的rails服务器时,我都会收到此错误:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
在升级之前,数据库在使用rails 3.0时运行良好。我该如何解决这个问题?
答案 0 :(得分:6)
修正了它。问题是postgresql正在侦听5433而不是5432.刚刚更改了database.yml文件中的端口。
答案 1 :(得分:3)
这是无法找到服务器时的标准错误消息。大多数情况下,这只是意味着你没有启动服务器(在标准端口5432上使用数据库集群)。
在使用postgres 9.1的Ubuntu上,如果安装正确,你会:
pg_ctl start
您必须是用户root
或postgres
。或者一般的方法:
sudo /etc/init.d/postgresql-9.1 start
如果Ubuntu安装了Martin Pitt的Debian包装器(这是Debian的标准,不确定Ubuntu):
pg_ctlcluster 9.1 main start
man pg_ctl
答案 2 :(得分:0)
似乎有些Linux发行版提供了一个postgresql服务器,其unix域套接字位于不同于通常的地方(/ tmp)。对于psql,您可以通过-h参数提供path_to_the_socket,例如:
psql -h /tmp/ mydatabasename
(你可以用它来测试它是否真的有效) 也许ruby有办法在其连接器设置中提供相同的设置。