The first of these methods
First of all, it's generally seen online.
- Close Service
windows
Under in C:\ProgramData(隐藏文件夹)\MySQL\MySQL Server 5.7\my.ini
the [mysqld]下
addskip-grant-tables
- Restart the service, login again now no password required
- Delete the original sentence
skip-grant-tables
, and then restart the service on the OK
But I follow this method in the third step of the time still need a password, if a classmate is like me, you can try the following method
The second method of
- Close Service
windows
Under in C:\ProgramData\MySQL\MySQL Server 5.7\my.ini
the [mysqld]下
addskip-grant-tables
- In a cmd window just enter
mysqld --skip-grant-tables
, and then open the second window direct input mysql
can be directly into the
Change password, following several commands
use mysql
update user set authentication_string=password(‘密码‘) where user="用户" and host=‘localhost‘;
flush privileges;
- Delete the original sentence, restart the
skip-grant-tables
service
MySQL5.7 Forgot Password Solution