ruby - 无法通过 Sequel 连接到 Postgres

标签 ruby postgresql sequel padrino

我正在尝试将 Padrino 与 Sequel 和 Postgres 一起使用,但没有成功连接。

在我的 pg_hba.conf 中,我将 postgres 用户设置为“信任”,因此不需要密码(并且可以在没有密码的情况下使用 PgAdmin 登录)。

# TYPE  DATABASE        USER            ADDRESS                 METHOD
  local all             postgres                                trust

我的 Padrino 连接如下所示:

Sequel::Model.plugin(:schema)
Sequel::Model.raise_on_save_failure = false # Do not throw exceptions on failure
Sequel::Model.db = case Padrino.env
  when :development then Sequel.connect(:adapter=>'postgres', :host=>'localhost', :database=>'padrino_template_development', :user=>'postgres', :password=>'', :loggers => [logger])
  when :production  then Sequel.connect("postgres://localhost/padrino_template_production",  :loggers => [logger])
  when :test        then Sequel.connect("postgres://localhost/padrino_template_test",        :loggers => [logger])
end

然后当我尝试运行 rake 任务 sq:create

我收到这条消息

rake sq:create
=> Creating database 'padrino_template_development'
Password: 
createdb: could not connect to database postgres: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"
<= sq:create executed

我在这里做错了什么?

最佳答案

OK 在这里找到了答案,问题是我使用的 PgAdmin3 版本有一个错误,导致 1970 年我更改密码时用户无效。

可以找到解决方案here

关于ruby - 无法通过 Sequel 连接到 Postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19874403/

相关文章:

ruby - 续集 gem : Handling invalid date values gracefully

ruby - Sql中的多行插入

ruby-on-rails - M1 MBP Rails db :create is throwing an error for msgpack

ruby - 有没有办法并行运行 cucumber 场景

ruby-on-rails - 如何在 Rails3.1.12 和 Ruby1.9.3 中将 SameSite 属性设置为 'None; Secure'

postgresql - 如何解释 stddev_time 和 hit_percent

PostgreSQL 自定义周数 - 包含 2 月 1 日的第一周

sql - 如果没有非空值列,如何选择空列值行

mysql - 在 Sequel::Model 中使用另一个数据库中的表

"this"的 Ruby 模拟(从内部访问类实例)