If you get this error you need to stop mysql first
/etc/init.d/mysql stop
Once done follow the below steps,
$ mysqld_safe –skip-grant-tables &
$ mysql -u root
$mysql> UPDATE user SET Password=PASSWORD(‘your password’) where USER=’root’;
$ /etc/init.d/mysql restart
Now $ mysql -u root -p
password: enter your new password here
Done you are in Mysql now
