mysql Forgot your password (Changing the root password)

1. Administrator, open cmd, type NET STOP mysql , mysql stop

2. Switch to the mysql installation directory (Example: S: \ mysql \ mysql- 8.0.18-winx64 \ mysql-8.0.18-winx64 \ bin), type mysql -share-Memory-Grant---skip Tables , skip authenticate

3. When complete step 2, the cursor will flash, there will be no new line came out, this time again as an administrator to open another cmd, switch to the mysql installation directory,

     You can type directly to log mysql

     You can also type mysqld -uroot -p, prompted for a password, any password can enter, but can also directly enter or ctrl + c

4. change Password

     flush privilege;

     alter user 'root' @ 'localhost ' identified by '( the password you want to modify)' ;

     exit or quitd

5. Then start mysql, type net start mysql, switch to the directory, type mysql -uroot -p enter password to login

 

Note: This method applies only to mysql8.0 and above versions, switching operation is limited to the directory (without configuration environment variable)

   

Guess you like

Origin www.cnblogs.com/pacifist/p/12015853.html