Introduction: in linux, if you forget the MySQL root Password, is there a way to reset the new password?
The answer is yes. Here is a simple method to reset the MySQL root Password:
1. Edit MySQL configuration file my. cnf
Vi/etc/my. cnf # edit the file, find [mysqld], and add a line of skip-grant-tables below
[Mysqld]
Skip-grant-tables
: Wq! # Save and exit
Shutdown-r now # restart the system
2. log on to the MySQL console.
Mysql-uroot-p # Press enter directly. You do not need to enter the root password.
3. Modify the root password
Update mysql. user set password = password ('000000') where User = "root" and Host = "localhost ";
Flush privileges; # refresh the System Authorization Table
4. Cancel skip-grant-tables in/etc/my. cnf
Vi/etc/my. cnf: edit the file, find [mysqld], and delete the line skip-grant-tables.
: Wq! # Save and exit
5. Restart mysql
Service mysqld restart # restart mysql. At this time, the mysql root password has been changed to 123456.
6. log on to the mysql console.
Mysql-uroot-p # enter the mysql Console
123456 # enter the password
So far, this is done.