Reputation:
I am trying to create a database and connect it with my rails app.
When I try to check if my database are properly connected via:
rails db:schema:dump
It gives me the ff error:
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)
This blows my mind as did used the exact password when I created the 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
I did try this:
grant all on simple_cms_development.* to 'rails_user'@'localhost' identified by '<password>';
flush privileges;
But did not solve my issue. Any help please?
I really need to solve this to move forward!
Upvotes: 1
Views: 1749
Reputation: 79
The SQL command you need to run is:
GRANT ALL PRIVILEGES ON test_project_development.* to 'railsuser'@'localhost'
IDENTIFIED BY 'grace0512';
Please also run this command immediately after to be consistent:
GRANT ALL PRIVILEGES ON test_project_test.* to 'railsuser'@'localhost'
IDENTIFIED BY 'grace0512';
There is no need to use flush privileges as MySql automatically reloads the grant tables.
If that did not work, did you run bundle install on command line in your project root after you updated database.yml? if so, recheck if you mispelled the username or password.
Upvotes: 0
Reputation: 23
Have you fixed it yet?
I changed it slightly and put
GRANT ALL PRIVILEGES ON demo_project_development.* to rails_user@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Although I still received Rails warnings, it successfully did a schema dump afterwards!
Upvotes: 1