我正在尝试将 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/