method One: SET PASSWORD
- u rootmysql > SET for ' Root '@'localhost'= PASSWORD ('newpass' );
method Two: Mysqladmin
" Newpass " "newpass" if Root has already set a password, take the second command
method Three: Update directly edit user table
mysql - u rootmysql > use Mysql;mysql > update user set Password " newpass ) where user " " ;mysql > FLUSH privileges ;
Loss of root password:Stop MySQL service
net stop MySQL
To the bin directory under the MySQL installation path, locate Mysqld-nt.exe
Mysqld-nt--skip-grant-tables The current window will stop
Open a command-line window to the MSYQL installation path under the Bin directory
mysql-u Rootmysql > Use MySQL; MySQL>updateuserset password=whereuser ="root"; MySQLprivileges; MySQL>exit
Open Task Manager, locate the MYSQLD-NT process and kill the process, and re-use MySQL to enter the database.
Translated from: http://www.linuxidc.com/Linux/2008-02/11137.htm