Http://www.cnblogs.com/yuxc/archive/2012/07/25/2607587.html
1. End the currently running MySQL process.
#/etc/init.d/mysql Stop
2. Run in MySQL Safe mode and skip permission verification.
#/usr/bin/mysqld_safe--skip-grant-tables
3. Re-open a terminal to log in to MySQL as root.
# mysql-u Root
4, modify the root user password.
mysql> use MySQL;
Reading table information for completion of table and column names
Can turn off this feature to get a quicker startup with-a
Database changed
mysql> Update user Set Password = Password (' root ') where user = ' root ';
Query OK, 3 Rows Affected (0.00 sec)
Rows Matched:3 Changed:3 warnings:0
Mysql> exit
5. End MySQL Safe mode and run MySQL in normal mode.
#/etc/init.d/mysql Restart
6. Try your newly modified password
Mysql> show grants for ' root ' @ ' 127.0.0.1 ';
mysql> flush Privileges;
Mysql> quit
1Mysql>Use MySQL2Reading table Information forCompletion of Table andcolumn Names3Can turn off this feature to get a quicker startup with-A4 5 Database changed6mysql> Update user Set Password = Password ('Root') Where User ='Root'7- ;8Query OK, 4 rows affected (0.06sec)9Rows Matched:4 Changed:4warnings:0Ten One A -Ysql> Select User,password fromuser; -+------------------+-------------------------------------------+ the| user | password | -+------------------+-------------------------------------------+ -| Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b | -| Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b | +| Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b | -| Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b | +| Debian-sys-maint | *422d1af27e5e185185fe7e0c56187ab7396542d0 | A+------------------+-------------------------------------------+ at5 rowsinchSet (0.00sec) - -Mysql>
Forgot MySQL password reset method under Ubuntu