Windows:
1. Log into the system with the system administrator.
2. Stop the MySQL service.
3. Go to the Command Window (CMD) and enter the MySQL installation directory, for example, my installation directory is c:\mysql, enter C:\mysql\bin
4. Skip permission Check to start MySQL,
C:\mysql\bin>mysqld-nt--skip-grant-tables
5. Reopen a CMD window, enter the C:\mysql\bin directory, and set a new password for root
C:\mysql\bin>mysqladmin-u root flush-privileges password "NewPassword"
C:\mysql\bin>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"
. Restart MySQL Server
kill-9 MySQL Process
Mysqld_safe--user=mysql--skip-grants-table
Excerpted from http://tieba.baidu.com/f?kz=175650226
MySQL forgot password what to do?