rake db:setup 导致 fe_sendauth 未提供密码的错误结果

13
当我执行以下命令: rake db:setup 我会得到以下输出:
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

我的database.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文件,但是并没有起到任何帮助。


2
我看到 postfresql 被作为适配器而不是 postresql。这是一个错误吗?能否请您添加 ActiveRecord::Base.connection.instance_variable_get(:@config) 的输出结果? - Paritosh Piplewar
你能通过命令行或pgadmin连接到PostgreSQL吗? - Sachin Singh
尝试连接指定主机:psql -U my_user -h localhost。如果它要求输入密码,则您应该再次编辑您的pg_hba.conf文件。 - Timothy Kovalev
7个回答

3

3

朋友,我曾经也遇到过同样的问题。我的解决方案是为每个环境添加凭据并在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

尝试指定您想要执行此操作的Rails环境,例如:

RAILS_ENV=test rake db:setup

1
"

no password supplied 意味着您没有在 database.yml 中提供密码给 posgresql 服务器。

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

现在尝试:

RAILS_ENV=TEST bundle exec rake db:setup

"

0

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

password: ""

0

no password supplied 表示需要提供密码,但你没有指定密码。请在你的 database.yml 文件中添加正确的密码。


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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接