我一直在尝试为我刚开始从事的项目设置我的 ruby on rails 开发环境。我在 Ubuntu 12 上安装了 Ruby 1.9.3、Rails 3.2 和 postgresql 9.1.4,当我尝试 rake db:create:all 时,我收到消息:
/var/lib/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in `initialize': could not connect to server: No such file or directory (NameError)
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
然后我补充说:
主机:本地主机
端口:5432
到我的 database.yml 文件,它让我执行 db:create:all 和 db:migrate,但是当我在本地运行 rails 服务器时,它仍然有同样的错误。
我已经检查过 postgresql 服务器正在运行,确实如此(我也知道它正在运行,因为 rake 之前工作过),并且尝试了全新安装的 postgresql。为了完成这项工作,我可能缺少什么?
最佳答案
您确定您的 postgres 服务器正在运行吗?
如果您执行 ps -ef|grep postgres
,您应该会看到如下内容:
[root@haddock ~]# ps -aef|grep 'postgres'
postgres 5963 5475 0 21:28 ? 00:00:00 /usr/postgresql/bin/postmaster -D <your postgres directory>
postgres 5972 5963 0 21:28 ? 00:00:00 postgres: writer process
postgres 5973 5963 0 21:28 ? 00:00:00 postgres: wal writer process
postgres 5974 5963 0 21:28 ? 00:00:00 postgres: autovacuum launcher process
postgres 5975 5963 0 21:28 ? 00:00:00 postgres: stats collector process
admin 6750 6607 0 21:30 ttyS0 00:00:00 grep postgres
关于ruby-on-rails - ruby on rails 无法在本地连接到 postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10922335/