ruby-on-rails - ruby on rails 无法在本地连接到 postgresql

标签 ruby-on-rails ubuntu postgresql-9.1

我一直在尝试为我刚开始从事的项目设置我的 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/

相关文章:

ruby-on-rails - 如何在 Rails 应用程序模板中使用 postgres?

html - 类不适用于提交按钮

mysql - '𠂉' 不是有效的 unicode 字符,但在 unicode 字符集中?

c++ - ROS hydro + OpenNI2 + NiTE2 on Linux Ubuntu 12.04 NiTE 初始化失败

postgresql - 如何向数据库中插入新行并获取结果的主键

ruby-on-rails - 如何在rails3.1中使用ajax?

使用 exec() 编译和运行 c 程序

git - 如何将 git clone 与 ssh 保护的 gitolite 服务器一起使用

postgresql - PostgreSQL 中奇怪的 ORDER BY 顺序

centos - 从服务器中删除页脚数据