在 FATAL 没有 pg_hba.conf 条目后 Rake 中止 [英] Rake aborted after FATAL no pg_hba.conf entry

查看:37
本文介绍了在 FATAL 没有 pg_hba.conf 条目后 Rake 中止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 CentOS 6.5 上运行我的 Rails 4.0.4 (Ruby 2.1.1) 应用程序

尝试迁移时失败:

$ rake db:migrate耙子中止!PG::ConnectionBad:致命:没有主机::1"、用户my_user"、数据库my_database_dev"的 pg_hba.conf 条目,SSL 关闭

我不知道如何解决这个问题.在我的 mac 设置上一切正常,无需触摸 pg_hba.conf.

欢迎任何线索.

我创建了 my_user 如下:

CREATE ROLE my_user WITH CREATEDB SUPERUSER LOGIN;

并允许 my_user 在 pg_hba.conf

中以信任"访问所有数据库

我的config/database.yml 包含

开发:适配器:postgresql主机:本地主机编码:unicode数据库:my_database_dev池:5用户名:my_user密码:模板:模板0

解决方案

看起来 rake 出于某种原因传递了一个糟糕的 host,正如我所假设的 ::1 不是您服务器的名称(它看起来更像是来自 Postgres 配置的各种 IP 掩码).( ::1 是 IPv6 本地主机,根据 Doon 下面的评论.)

不确定为什么相同的代码可以在您的 Mac 上正常运行,但我认为您的 Rails 配置中涉及一个 database.yml?您可能想尝试在其中指定 host 属性(如果您的服务器是本地的,它可以指向 localhost),看看是否有帮助.

主机:本地主机

如果 Postgres 不在您安装 Postgres 的标准端口(5432,默认安装),您还需要为 port 包含一个.

Trying to run my Rails 4.0.4 (Ruby 2.1.1) application on CentOS 6.5

Failing when I attempt to migrate:

$ rake db:migrate
rake aborted!
PG::ConnectionBad: FATAL:  no pg_hba.conf entry for host "::1", user "my_user", database "my_database_dev", SSL off

I am not sure how to tackle this one. On my mac setup all worked fine without having to touch the pg_hba.conf.

Any lead is welcome.

I have created my_user as follow:

CREATE ROLE my_user WITH CREATEDB SUPERUSER LOGIN;

And allowed my_user to access all database with 'trust' in the pg_hba.conf

my config/database.yml contains

development:
  adapter:  postgresql
  host:     localhost
  encoding: unicode
  database: my_database_dev
  pool:     5
  username: my_user
  password:
  template: template0

解决方案

It looks like rake is for some reason passing a bad host, as I assume ::1 is not the name of your server (it looks more like an IP mask of sorts from the Postgres config). (Edit: ::1 is IPv6 localhost, per Doon's comment below.)

Not sure offhand why the same code would work OK on your Mac, but I assume there's a database.yml involved in your Rails config? You may want to try specifying a host attribute in there (it can point to localhost if your server is local) and see if that helps.

i.e.

host: localhost

You'd also want to include one for the port if Postgres is not on the standard port for your Postgres install (5432 with a default install).

这篇关于在 FATAL 没有 pg_hba.conf 条目后 Rake 中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆