How to fix MySQL error: Access denied for user

Well, here it goes, my first blog post. Let’s kick it off with a MySQL error.

Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO)

The issue surfaced after creating the first model in a Ruby on Rails app and then trying to start rails server in development. It turns out config/database.yml wasn’t set up with the right MySQL credentials. After saving this file with the correct username and password, and then restarting rails server, my website didn’t receive the error anymore.