title: Mysql2::Error::ConnectionError: Access denied for user 'rails_user'@'localhost' (using password: YES)
body: <p>I get the following error when I run 'rails db:schema:dump' after initially configuring my Ruby on Rails project and checking the schema set-up for my Mysql database, which should be empty in terms of data so far the tables I've created:</p>
  
  <pre><code>Mysql2::Error::ConnectionError: Access denied for user 'rails_user'@'localhost' (using password: YES)
  </code></pre>
  
  <p>I enter mysql -u root -p in the command line and create the following databases:</p>
  
  <pre><code>CREATE DATABASE simple_ex_development;
  
  CREATE DATABASE simple_ex_test;
  </code></pre>
  
  <p>Now instead of using root user to connect to my newly created databases (which isn't an optimal security practice), I define a new user that the rails application can use to connect to them called 'rails_user' as follows:</p>
  
  <pre><code>GRANT ALL PRIVILEGES simple_ex_development.* TO 'rails_user'@'localhost' IDENTIFIED BY 'blahpassword'
  
  GRANT ALL PRIVILEGES simple_ex_test.* TO 'rails_user'@'localhost' IDENTIFIED BY 'blahpassword'
  </code></pre>
  
  <p>Then I exit mysql and go to my rails application config/database.yml file and update the username and password, respectively:</p>
  
  <pre><code>default: &amp;default
    adapter: mysql2
    encoding: utf8
    pool: &lt;%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %&gt;
    username: rails_user
    password: blahpassword
    host: localhost
  </code></pre>
  
  <p>Then when I go back to the terminal and run 'rails db:schema:dump' I get the following error above, when I'm not expecting to get anything at all. I've read other stackoverflow posts here touching on similar issues and hinting that it might be anonymous user. </p>
  
  <p>Why am I getting this error message and how can I resolve it?</p>
  
  <p>Any pointers here would be great, thank you!</p>
  
  <p>P.S. When I do run rails server I can see the web app on localhost but again, I'm not sure if it's being configured properly to the new user and password versus root and my root password.</p>