In the Vagrant provisioning script we have creation of mysql user "vagrant" who can do anything:
/usr/bin/mysql -u root -e "GRANT ALL ON *.* TO 'vagrant'@'localhost';"One day we upgraded mysql from 5.1 to 5.5 and this command started to throw an error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
We were struggling with it for a while - comparing my.cnf file and other configuration, checking rights on socket, tables etc. Finally the solution was easy, we just forgot to start mysql upgrade command :)
Solution was:
mysql_upgrade -u rootAfter this everything works as expected for us.
Note: See that in the mysql command we don't use -p parameter, that's because we have user root also without password.
Note2: There are probably many situations where error "Access denied for user 'root'@'localhost'" can happen, this blogpost is just description of one situation with solution.