How to Reset the root Password of MySQL | Reset MySQL Password if you have lost the root Password
Step 1: Stop MySQL instance.
Step 2: Start MySQL in Safe mode with the mysqld_safe command and mention not to read the grant tables with all the MySQL database passwords.
Step 3: Now MySQL is now running without password protection. You now have to use the mysql -u root command to get the mysql> command prompt. ( -p flag is not required) As expected, you will not be prompted for a password.
Step 4: You will now have to use the mysql database which contains the passwords for all the databases on your system and modify the root password. In this case we are setting it to 123456.
Step 5: Exit MySQL and restart the mysqld server daemon.
The MySQL root user will now be able to manage MySQL using this new password.
Step 6: Use the following command to login to MySQL. The following method of login is not recommended, it just for example.