1, first net stop MySQL service, and switch to Task Manager, there is MySQL-related, it is best to close the process.
2, run the cmd command to switch to the MySQL installation bin directory, the following is my MySQL installation directory
CD D:\Program files\mysql\mysql Server 5.6\bin
Then execute the mysqld--skip-grant-tables (note that there is no semicolon behind it;)
The following message appears,
This command-line window does not close and then reopen a new command-line window. Note that there is sometimes a warning to ignore.
3. Open a new CMD window again. According to the above method to run to the bin directory, run the command: Mysql-u root-p, prompted to enter the password, direct return,
Such as
4. Execute command: Update mysql.user set Password=password (' root ') where user= ' root ';
The root user password is then set to root
5. Refresh execution: mysql> flush privileges;
Now you can log in again, the password changes successfully.
mysql5.6 forgot root password