Windows:
1. Log into the system with the system administrator.
2. Stop the MySQL service.
3. Go to the Command window and enter the MySQL installation directory, for example, my installation directory is c:mysql, enter C:mysqlbin
4. Skip permission Check to start MySQL,
C:mysqlbin>mysqld-nt–skip-grant-tables
5. Reopen a window, enter the C:mysqlbin directory, and set a new password for root
C:mysqlbin>mysqladmin-u root flush-privileges password "NewPassword"
C:mysqlbin>mysqladmin-u root-p shutdown
Replace the newpassword with the root password you want to use, and the second command will prompt you to enter a new password and repeat the password entered by the first command.
6. Stop MySQL Server and start MySQL in normal mode
7. You can link to MySQL with a new password.
Unix&linux:
1. Log in to the system with root or user running mysqld;
2. Use the KILL command to end the process of losing mysqld;
3. Starting MySQL Server with the –skip-grant-tables parameter
Shell>mysqld_safe–skip-grant-tables &
4. Set a new password for [email protected]
Shell>mysqladmin-u root flush-privileges password "NewPassword" 5. Restart MySQL Server
GRANT all privileges on * * to [e-mail protected]% identified by ' 123′
How to solve Linux:
Turn off MySQL
Then, Safe_mysqld–skip-grant-tables
Start MySQL.
Mysql-u Root
mysql> use MySQL
mysql> UPDATE user SET password=password (' xxx ') WHERE user= ' root ';
mysql> FLUSH privileges;
MySQL forgot password what to do?