How to Reset a Forgotten MySQL Root Password

service mysqld stop Then start the mysql daemon skipping the grants table which stores the password.

mysqld_safe --skip-grant-tables
This will start the mysql daemon but will not exit. You’ll need to connect again to the server on another terminal. This time you can login as root without the password.
mysql --user=root mysql
Then this command will reset the root password.
update user set password=PASSWORD('new-password') where user='root';
Flush privileges and you are done.
flush privileges;
Do take note that resetting the root password has its inherent risks. So make sure you understand what you are doing before you execute a command. Take note that I was running as (linux) root to execute the reset.  ]]>