The following steps are to reset the password for a user in case you forgot, this would also solve your mentioned error.
First, stop your MySQL:
sudo /etc/init.d/mysql stop or sudo service mysqld stop
Now start up MySQL in safe mode and skip the privileges table:
sudo mysqld_safe --skip-grant-tables &
and then Login with root:
And assign the DB that needs to be used:
Now all you have to do is reset your root password of the MySQL user and restart the MySQL service:
update user set password=PASSWORD("YOURPASSWORDHERE") where User='root'; flush privileges;
quit and restart MySQL:
sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start Now your root password should be working with the one you just set, check it with:
mysql -u root -pand.... walaaaaa... it works!!!