Rails and Mysql2 Access denied for user 'root'@'localhost' (using password: NO) Rails and Mysql2 Access denied for user 'root'@'localhost' (using password: NO) ruby-on-rails ruby-on-rails

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


for me helped

$ mysql -u root -pmysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypassword')

and in databse.yml

development:adapter: mysql2database: mydbhost: localhostusername: rootpassword: "mypassword" #I had an empty string here before

thanks to @spongezh22


seems like your user cannot connect to the mysql DB, try this 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

And you database yml file should be like

development: adapter: mysql2 database: mydb host: localhost username: root password: mypass


I just copied and pasted the above (below) to my rails yml file and it worked!!

development:adapter: mysql2database: mydbhost: localhostusername: rootpassword: mypass