1. Stop the MySQL process is running
under Linux, run killall -TERM mysqld
under Windows, if you write services can run: net stop mysql, if not loaded as a service, it can be closed directly in Task Manager.
2, start in Safe mode MySQL
under Linux, run mysqld_safe --skip-grant-tables &
Under Windows, at the command line to run the X-: /MySQL/bin/mysqld-nt.exe --skip-Grant-the Tables
3, complete after the above two steps can not have a password to enter the MySQL
under Linux, run mysql -u root entered
under Windows, run X: / MySQL / bin / mysql -u root enter
4, change password
This we can be modified directly in the mysql client prompt the user information table, (the first sentence is to open the system database "mysql", the second sentence is a look at what the current user information table from which users can access a host data, the third sentence is directly modify the user's password, the fourth sentence is to update user rights to take effect immediately):
>use mysql;
>select host, user, password from user;
>update user set password=password("NewPassword") where user="root";
>flush privileges;
5, exit mysql client operating system into the console, execute the following two commands:
killall -TERM mysqld
service mysqld start