MySql forget the root password, update password method

First, avoid close Login Mysql service

1. Run cmd as an administrator to see if mysql has been launched, if already started, stop: net stop mysql.

net stop mysql

2. Switch to the MySQL installation path: D:\environment\mysql-5.7.25-winx64\bin; if already equipped with environment variables, can not switched. At the command line, type:mysqld -nt --skip-grant-tables

mysqld -nt --skip-grant-tables

Here Insert Picture Description
3. Administrator RestartA cmd command window, type: mysql -uroot -p, do not lose your password to enter directly into the database.

mysql -uroot -p

Here Insert Picture Description

Second, retrieve password

If you do not want to change your password, just want to see the original password, you can execute the statement from the command lineselect host,user,authentication_string from mysql.user;

 select host,user,authentication_string from mysql.user;

Here Insert Picture Description

Third, change passwords

In turn execute the following statement at the command line

use mysql
update user set authentication_string=password("123456") where user="root";// 'new_pass' 这里改为你要设置的密码
flush privileges;
quit

Here Insert Picture Description

Restart MYSQL, enter the password you can!

Here Insert Picture Description
__________________prefect

Published 43 original articles · won praise 80 · views 8719

Guess you like

Origin blog.csdn.net/qq_44717317/article/details/104000148