Ruby on Rails MYSQL error Access denied for user 'root@localhost'

Seems like your user cannot connect to the MySQL DB. Try these commands in your console:

mysql -u root -p

And when prompted, give the password as 'admin'

If this is possible, then you should be good to go.


The password is wrong for the root user in your config/database.yml file. You can always use the mysqladmin command to change the root user's password if you forgot it.


This worked for me

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password’;


mysql> FLUSH PRIVILEGES;
mysql> exit;

After the above commands try

mysql -u root -p