【问题标题】:rake db:setup results in fe_sendauth no password suppliedrake db:setup 导致 fe_sendauth 未提供密码
【发布时间】:2014-09-29 08:17:54
【问题描述】:

当我跑步时: 耙分贝:设置

我明白了:

fe_sendauth: no password supplied

Couldn't create database for {"adapter"=>"postfresql", "encoding"=>"unicode",
"host"=>"localhost", "pool"=>5, "username"=>"my_user", "password"=>nil,  
"database"=>"my_db_test"}

-- enable_extension("plpgqsl")
rake aborted


Tasks: TOP => db:schema:load

我的数据库.yml:

connection: &connection
adapter: postgresql
encoding: unicode
host:     localhost
pool: 5
username: my_user
password:

development:
  <<: *connection
  database: my_db_development

test: &test
  <<: *connection
  database: my_db_test

已经像这个问题一样更改我的 pg_hba.conf:Trying to set up postgres for ror app, getting error - fe_sendauth: no password supplied 但这一点帮助都没有。

【问题讨论】:

  • 我将postfresql 视为适配器而不是postresql。这是一个错误吗?你能添加ActiveRecord::Base.connection.instance_variable_get(:@config)的输出吗?
  • 你能通过命令行或pgadmin连接到postgres吗?
  • 尝试连接指定主机:psql -U my_user -h localhost。如果它要求输入密码,那么您应该再次编辑您的pg_hba.conf

标签: ruby-on-rails ruby postgresql ubuntu pg


【解决方案1】:

我的朋友,我也有同样的问题。我的解决方案是为每个环境添加凭据,并在值 localhost 中启用主机..

像这样:

development:
<<: *default
database: SM_development
username: user
password: xxxx

host: localhost

test:
<<: *default
database: SM_test
username: user
password: xxxxxx

production:
<<: *default
database: SM_production
username: user
password: xxxxxx

【讨论】:

    【解决方案2】:

    这是一个数据库连接问题。

    尝试直接连接你使用的数据库。如果它询问密码,那么您应该在 database.yml 文件中使用相同的密码。

    检查此链接 http://guides.rubyonrails.org/configuring.html#configuring-a-postgresql-databaseRuby on Rails: How can i edit database.yml for postgresql?

    希望这个链接对你有帮助

    【讨论】:

      【解决方案3】:

      no password supplied 表示您尚未从 database.yml 向 posgresql 服务器提供密码。

      尝试从 pgadmin 或终端连接到 posgresql 服务器。将相同的密码(您用于通过终端/pgadmin 登录的密码)添加到您的 database.yml。

      现在试试:

      RAILS_ENV=TEST bundle exec rake db:setup

      【讨论】:

        【解决方案4】:

        如果您不想指定身份验证,请尝试从 .yml 文件中删除 username: password:

        【讨论】:

          【解决方案5】:

          尝试指定您要为哪个 Rails 环境执行此操作,例如:

          RAILS_ENV=test rake db:setup
          

          【讨论】:

            【解决方案6】:

            no password supplied 表示需要密码,但您未指定密码。将正确的密码添加到您的 database.yml 文件中。

            【讨论】:

              【解决方案7】:

              尝试使用引号提供“空”密码:

              password: ""
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2013-08-02
                • 1970-01-01
                • 2019-04-25
                • 2014-06-16
                • 1970-01-01
                • 1970-01-01
                • 2021-05-29
                • 1970-01-01
                相关资源
                最近更新 更多