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
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 login with the new password NewPassword
Linux forgot MySQL password