【问题标题】:rake db:create:all => FATAL: password authentication failed for user "foo"rake db:create:all => FATAL: 用户“foo”的密码验证失败
【发布时间】:2012-10-04 14:05:41
【问题描述】:

第一次尝试设置 postgresql 数据库。我正在使用this railscast。经过几个小时令人沮丧的问题,我得到了 rake db:create:all。现在我得到了错误:

password authentication failed for user "pgtest"

这是我的 pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

这是我的database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: pgtest_development
  pool: 5
  username: pgtest
  password: password

test:
  adapter: postgresql
  encoding: unicode
  database: pgtest_test
  pool: 5
  username: pgtest
  password: password

我先尝试了没有密码,但它给出了错误:

fe_sendauth: no password supplied

我做错了什么?谢谢:)

【问题讨论】:

  • 您的 postgres 密码无效是否已创建 pgtest 用户,请尝试使用 psql 或 pgadmin3 登录 postgres,然后检查
  • 我不确定这是否重要,但您的 database.yml 配置中没有 host
  • @ Amar,在 pgadmin3 中显示用户名“postgres”,所以我将 pg_hba.conf 更改为用户名 postgres,并且它旁边的密码是用户 postgres 的密码。它奏效了! =) 但是,让它成为用户 postgres 有问题吗?我认为这就像管理员用户或其他东西。谢谢!

标签: ruby-on-rails ruby rake rails-postgresql


【解决方案1】:

如果你只是对你的 pg_hba.conf 进行了修改,而没有 RELOADRESTART PostgreSQL 首先这样做。这些是您所描述的常见原因。

如果这没有解决它,那么您要么编辑了错误的 pg_hba.conf,要么您在文件中前面指定了您没有向我们展示的规则。按顺序排除这些情况。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-06
    • 2021-08-04
    • 1970-01-01
    相关资源
    最近更新 更多