【问题标题】:Ruby on Rails Authentication Error for postgrespostgres 的 Ruby on Rails 身份验证错误
【发布时间】:2018-03-02 05:51:59
【问题描述】:

我在本地创建了 Postgresql 数据库。 Postgre database

这是我的 database.yml 文件。 默认值:&默认值 适配器:postgresql 游泳池:5 超时:5000

development:
  <<: *default
  database: myrubyblog
  username: postgres
  password: Naruto1994.

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: myrubyblog
  username: postgres
  password: Naruto1994.

production:
  <<: *default
  database: myrubyblog
  username: postgres
  password: Naruto1994.

我已确保输入正确的密码,但我仍然收到此错误。

Error in the code

【问题讨论】:

  • 尝试从密码中删除点?另外,您如何创建您的数据库?你真的在 psql 上设置了这个密码吗?

标签: ruby-on-rails ruby postgresql authentication


【解决方案1】:

您可以添加本地主机,并确保您有带点或不带点的密码(Naruto1994),我的建议是在每个环境(开发、测试和生产)之间拆分数据库名称

development:
  adapter: postgresql
  encoding: unicode
  database: myrubyblog_development
  host: localhost
  username: postgres
  password: Naruto1994.  
  pool: 5

test: 
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: myrubyblog_test
  username: postgres
  password: Naruto1994.  
  pool: 5

production:
  adapter: postgresql
  encoding: unicode
  database: myrubyblog_production
  pool: 5
  host: localhost
  username: #env_variable
  password: #env_variable

【讨论】:

    【解决方案2】:

    这样的消息表明你联系了服务器,它愿意与你交谈,但直到你通过了 pg_hba.conf 文件中指定的授权方法。

    试试这个:

    // set new password for user "postgres"
    $sudo su postgres -c 'psql --username=postgres'
    ALTER USER postgres with encrypted password 'your_password';
    //change pg_hba.conf
    local all postgres md5
    

    然后重启 postgres。

    这篇文章可能对你有所帮助:Postgresql: password authentication failed for user "postgres"

    【讨论】:

      【解决方案3】:

      您只需将host: localhost 添加到每个环境。例如

      development:
        <<: *default
        database: myrubyblog
        host: localhost
        username: postgres
        password: Naruto1994.
      

      【讨论】:

        猜你喜欢
        • 2018-04-27
        • 2015-08-08
        • 2011-02-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-09-23
        相关资源
        最近更新 更多