ruby-on-rails - PG错误不知道如何调试

标签 ruby-on-rails postgresql

Exiting
/Users/judyngai/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record    /connection_adapters/postgresql_adapter.rb:1216:in `initialize': could not connect to          server: No such file or directory (PG::Error)
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

我通读了一些帖子,有人建议添加

主机:本地主机

到database.yml文件

然后我得到了这个新错误

Exiting
/Users/judyngai/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record        /connection_adapters/postgresql_adapter.rb:1216:in `initialize':      could not connect to server: Connection refused (PG::Error)
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?

有人能给我指出正确的方向吗?

我认为我没有提供足够的信息

当我这样做的时候

psql --version
psql (PostgreSQL) 9.2.4

which psql 
/usr/local/bin/psql

我的机器上确实安装了 psql

这是我的 database.yml 文件

test:
  adapter: postgresql
  encoding: unicode
  database: pinny_test
  pool: 5
  username: judyngai
  password:
  host: localhost

development:
  adapter: postgresql
  encoding: unicode
  database: pinny_development
  pool: 5
  username: judyngai
  password:
  host: localhost

我取消了生产部分的注释。

最佳答案

看来您的 PostgreSQL 配置有误。您需要更改 pg_hba.conf 中的配置。可以看到这个答案https://stackoverflow.com/a/7696398/1405852

关于ruby-on-rails - PG错误不知道如何调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16550900/

相关文章:

sql - 在sql中,长度函数是O(1)还是O(length)

mysql - acts_as_api 和项目符号 N+1 查询

mysql - 在 Rails 中对模型进行排名的最佳方式是什么

postgresql - postgresql 上带有全文搜索的键集分页

javascript - 如何将数据库的多个表值提取到动态选择框中

java - 从 PostgreSQL 创建 XML?

Jquery,向元素添加类

ruby-on-rails - rails 如果 object.nil?那么魔术 '' 在意见?

ruby-on-rails - Rails 视频嵌入 gem,服务

postgresql - 即使增加了 work_mem 大小,性能也没有提高