How to Reset MySQL root Password on CentOS
Stop the MySQL process
$ service mysqld stop
Once MySQL has stopped
Restart it with the –skip-grant-tables option
$ mysqld_safe --skip-grant-tables &
Connect to MySQL using the root user.
$ mysql -u root
Once logged in, you should see the following prompt:
mysql>
Tell MySQL which database to use:
mysql> use mysql;
Enter the new password for the root user as follows:
mysql> UPDATE user SET password=PASSWORD("YOUR NEW PASSWORD HERE") WHERE User='root';
Flush the privileges:
mysql> flush privileges;
Exit MySQL:
mysql> quit
Now stop MySQL again:
$ service mysqld stop
Now restart MySQL and test your new login.
$ service mysqld restart
$ mysql -u root -p