service mysqld stopThen start the mysql daemon skipping the grants table which stores the password.
mysqld_safe --skip-grant-tablesThis 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 mysqlThen 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. ]]>