Install mysql

Specific operation steps refer to: www.runoob.com/mysql/mysql…

2. Configure environment variables

Mysql > alter database forget password

  1. Open the CMD command line and enter the command line to stop the mysql service

net stop mysql

  1. Enter the command line to enable the MySQL service to skip password authentication

mysqld --console --skip-grant-tables --shared-memory

  1. Open a new CMD, enter the command line, and log in to MySQL without password

mysql -u root -p

  1. The password is left blank. The command line is as follows:
use mysql
update user set authentication_string='' where user='root';
Copy the code

  1. Run the quit command to exit mysql

  2. Disable MySQL services started with -console –skip-grant-tables –shared-memory

  3. Enter the command line to start the mysql service

net start mysql

Note: Open CMD command line as administrator, otherwise an error will be reported, system error will occur

  1. Step 4 Log in to the MySQL database without a password because the password is empty. Then change the password.
Mysql -u root -p ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password ';Copy the code

  1. Verify that the password is successfully changed. If the login succeeds, the password is successfully reset
Quit mysql -u root -p // Enter the new password. If the login succeeds, the password is reset successfullyCopy the code