rake db:为用户创建密码验证失败

时间:2018-01-11 10:34:50

标签: ruby-on-rails ruby authentication

在运行命令rake db:create时,系统会抛出postgresql authentication fails

FATAL:  password authentication failed for user "postgres"
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "username"=>"postgres", "password"=>"password", "timeout"=>5000, "host"=>"localhost", "database"=>"rails-sample-guestbook-master_development"}
rake aborted!

database.yml文件

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5
  username: supranimbus
  password: 123456789
  timeout: 5000
  host: localhost
development:
  <<: *default
  database: rails-sample-guestbook-master_development

test:
  <<: *default
  database: rails-sample-guestbook-master_test

production:
  <<: *default
  database: rails-sample-guestbook-master_production

1 个答案:

答案 0 :(得分:0)

我想问题是postgresql上的设置密码如果您不记得默认密码,请转到 pgAdmin 点击打开信息中心,然后左侧边栏看下面的内容图像

enter image description here

点击属性... ,然后会打开一个模式,如下图所示

enter image description here

并点击定义标签,然后查看密码字段并设置新密码,请记住postgres用户名的密码。

这是用于密码设置的!

现在更新您的database.yml文件,如下所示

default: &default
  adapter: postgresql
  encoding: unicode
  username: postgres
  password: 123456 #=> which you set for postgres
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: project_development

希望能提供帮助