Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )
First of all, stop mysql service
sudo service mysql stop;
Then, execute the following statement, which is running in the background &
sudo mysqld_safe --skip-grant-tables &;
At this time, press Enter, enter mysql hit enter to log successful;
Input associated with the operation of the database you want to use mysql
The direct use of sql statement to update the password
update user set password = password ( 'where the new password is set') where user = 'root';