Lost root password recovery method
-
- close the mysql service
net stop mysql
-
- In administrator mode, enter the command
mysqld --shared-memory --skip-grant-tables --console
Note: This command will not end, do not close the window, open a new command window to continue
-
- Open the command prompt and directly use root to connect to the database (no password required)
mysql -uroot
-
- Set the root account password in the mysql.user table to an empty string
update mysql.user set authentication_string = '' where user = 'root' ;
-
- Refresh permissions (this step is not necessary, and can also be solved by restarting the database)
flush privileges ;
-
- close
步骤 2
open window
- close
CTRL + C 强制中断服务,并关闭窗口 (也可以直接关闭窗口)
-
- Open the task manager CTRL + SHIFT + ESC, find mysqld in the process, if there is, end the process
This step is mainly to prevent the mysqld service not being closed in step 6
-
- Restart the MySQL service
net start mysql
-
- Link MySQL service
-- 在步骤4 中,已经将密码设置为 空
mysql -uroot
-
- reset root password
alter user root@'%' identified by '新密码' ;
-
- Refresh permissions
-- 或者重启MySQL服务
flush privileges ;