1. Stop the MySQL service: net stop MySQL

2. Go to the mysql installation directory and clear the data directory file

3. Enter mysqld –skip-grant-tables and press Enter. –skip-grant-tables means skip permission table authentication when starting MySQL service.

4. Start MySQL service: net start MySQL

Mysql -u root -p mysql>


Query the current user name and password
select  host,  user,  authentication_string  from  mysql.user ;
# change password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword'
# Note: The authentication_string: field indicates the user password. (old mysql password)
Copy the code