title: ActiveRecord::ConnectionNotEstablished: Access denied
body: <h2>want to　　</h2>
  <p>Eliminate this error,
  I want to connect rails and MySQL</p>
  <pre><code>ActiveRecord::ConnectionNotEstablished: Access denied for user 'wdyluser'@'localhost' (using password: YES)
  
  Mysql2::Error::ConnectionError: Access denied for user 'wdyluser'@'localhost' (using password: YES)
  </code></pre>
  <h2>Current status</h2>
  <p>I'm making an app with rails.<br />
  DB used SQLite at first, but decided to move to MySQL.</p>
  <p>Finally,When I typed this command, I got the above error and got stuck.</p>
  <pre><code>bundle exec rake db:create
  </code></pre>
  <p>↓</p>
  <pre><code>ActiveRecord::ConnectionNotEstablished: Access denied for user 'wdyluser'@'localhost' (using password: YES)
  
  Mysql2::Error::ConnectionError: Access denied for user 'wdyluser'@'localhost' (using password: YES)
  </code></pre>
  <h2>Source</h2>
  <p>config/database.yml</p>
  <pre><code>default: &amp;default
    adapter: mysql2
    database: wdyldb
    username: wdyluser
    password: 00000
    host: 127.0.0.1
    encoding: utf8
  
  development:
    &lt;&lt;: *default
  
  test:
    &lt;&lt;: *default
  
  production:
    &lt;&lt;: *default
  </code></pre>
  <p>Gemfile</p>
  <pre><code>gem 'mysql2'
  # gem 'sqlite3', '~&gt; 1.4'
  </code></pre>
  <h2>I tried</h2>
  <ul>
  <li>Can I log in to MySQL</li>
  </ul>
  <pre><code>mysql -uwdyluser -p00000
  </code></pre>
  <p>↓</p>
  <p>ok (username and its password are correct)</p>
  <ul>
  <li>Does DB exist</li>
  </ul>
  <pre><code>mysql&gt; show databases;
  +--------------------+
  | Database           |
  +--------------------+
  | information_schema |
  | wdyldb             |
  +--------------------+
  2 rows in set (0.00 sec)
  </code></pre>
  <p>↓<br />
  Exists</p>
  <ul>
  <li>Does user exist and is it authorized?</li>
  </ul>
  <pre><code>mysql&gt; show grants for wdyluser@localhost;
  +--------------------------------------------------------------+
  | Grants for wdyluser@localhost                                |
  +--------------------------------------------------------------+
  | GRANT USAGE ON *.* TO `wdyluser`@`localhost`                 |
  | GRANT ALL PRIVILEGES ON `wdyldb`.* TO `wdyluser`@`localhost` |
  +--------------------------------------------------------------+
  </code></pre>
  <p>↓<br />
  Exists, has authority</p>
  <h2>environment</h2>
  <p>macOS BigSur 11.1<br />
  mysql  Ver 8.0.23<br />
  ruby 2.7.0p0<br />
  Rails 6.1.1</p>