Ruby on rails Mysql2::错误:拒绝用户访问';rails#u user'@';本地主机';(使用密码:是)

Ruby on rails Mysql2::错误:拒绝用户访问';rails#u user'@';本地主机';(使用密码:是),ruby-on-rails,mysql2,Ruby On Rails,Mysql2,我正在尝试创建一个数据库并将其与我的rails应用程序连接 当我尝试通过以下方式检查数据库是否正确连接时: rails db:schema:dump 它给出了ff错误: Mysql2::Error: Access denied for user 'rails_user'@'localhost' (using password: YES) bin/rails:4:in `require' bin/rails:4:in `<main>' Tasks: TOP => db:sche

我正在尝试创建一个数据库并将其与我的rails应用程序连接

当我尝试通过以下方式检查数据库是否正确连接时:

rails db:schema:dump
它给出了ff错误:

Mysql2::Error: Access denied for user 'rails_user'@'localhost' (using password:
YES)
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:schema:dump
(See full trace by running task with --trace)
Mysql2::错误:用户'rails\u user'@'localhost'的访问被拒绝(使用密码:
是的)
箱子/轨道:4:在'require'中
箱子/轨道:4:in`'
任务:TOP=>db:schema:dump
(通过使用--trace运行任务查看完整跟踪)
这让我震惊,就像我创建DB时使用的密码一样:

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: rails_user
  password: grace0512
  host: localhost

development:
  <<: *default
  database: test_project_development

# 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: test_project_test
default:&default
适配器:mysql2
编码:utf8
游泳池:5
用户名:rails\u用户
密码:grace0512
主机:本地主机
发展:

你修好了吗

我稍微改变了一下,把它放了进去

    GRANT ALL PRIVILEGES ON demo_project_development.* to rails_user@localhost IDENTIFIED BY 'password';
    FLUSH PRIVILEGES; 

虽然我仍然收到Rails警告,但它成功地完成了模式转储

您需要运行的SQL命令是:

GRANT ALL PRIVILEGES ON test_project_development.* to 'railsuser'@'localhost' 
IDENTIFIED BY 'grace0512';
还请在完成以下操作后立即运行此命令以保持一致:

GRANT ALL PRIVILEGES ON test_project_test.* to 'railsuser'@'localhost' 
IDENTIFIED BY 'grace0512';
不需要使用刷新权限,因为MySql会自动重新加载授权表


如果这不起作用,在更新database.yml之后,是否在项目根目录中的命令行上运行了bundle install?如果是,请重新检查用户名或密码是否有误

我知道这很难,但请确保
密码:grace0512
后没有空格。。当然,请将所有值包装在
中<代码>密码:“grace0512”
对我不起作用。
GRANT ALL PRIVILEGES ON test_project_test.* to 'railsuser'@'localhost' 
IDENTIFIED BY 'grace0512';