MySQL sometimes forgets the root password is a sad thing. This provides the password reset method under Windows and Linux.
Windows:
1. Log in to the system as a system administrator.
2. Open cmd-----net start to see if MySQL is started. Stop the net stop MySQL when you start the message.
3. My MySQL is installed under D:\usr\local\mysql4\bin.
4. Skip permission check to start MySQL.
D:\usr\local\mysql\bin\mysqld-nt--skip-grant-tables
5. Re-open cmd. Enter under D:\usr\local\mysql4\bin:
D:\usr\local\mysql\bin\mysqladmin-u root flush-privileges password "NewPassword"
D:\usr\local\mysql\bin\mysqladmin-u root-p shutdown This sentence prompts you to re-lose the password.
6. In cmd net start MySQL
7. It's done.
Linux:
One of the ways to recover MySQL root password
If you forget the MySQL root password, you can reset it in the following ways:
1.KILL off the MySQL process in the system;
Killall-term MySQLd
2. Start MySQL with the following command to start without checking permissions;
Safe_mysqld--skip-grant-tables &
3. Then log in to MySQL using the root user with a blank password;
Mysql-u Root
4. Change the password of the root user;
mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';
mysql> flush Privileges;
Mysql> quit
Restart MySQL and you will be able to log in with your new password.
Mysqlroot Password Recovery Method II
It is possible that your system does not have a SAFE_MYSQLD program (such as the Ubuntu OS I am using now, Apt-get installed MySQL), the following method can be restored
1. Stop mysqld;
Sudo/etc/init.d/mysql stop
(You may have other ways to stop mysqld running anyway)
2. Start MySQL with the following command to start without checking permissions;
MySQLd--skip-grant-tables &
3. Then log in to MySQL using the root user with a blank password;
Mysql-u Root
4. Change the password of the root user;
mysql> Update Mysql.user Set Password=password (' NewPassword ') where user= ' root ';
mysql> flush Privileges;
Mysql> quit
Restart MySQL
/etc/init.d/mysql restart
You can log in with the new password newpassword.
What do I do if I forget my MySQL password? MySQL Reset root password method