1. Stop MySQL First
/etc/init.d/mysqld stop
2. Use--skip-grant-table to start MySQL, ignoring authorization login verification.
Mysqld_safe--skip-grant-tables--user=mysql &
Mysql-u root-p <== Login time-space password.
Hint: The--skip-grant-tables parameter is added at startup to indicate that authorization table validation is ignored.
This goes in, no need for a password to enter MySQL
You can use update to change your password after you go in.
Mysql>update Mysql.user Set Password=password ("liucong456") where user= ' root ' and host= ' localhost '
Mysql>flush privileges;
Next you need to restart MySQL, remember to reboot.
Reboot is with the command
Mysqladmin-u root-p ' 456 ' shutdown
/etc/init.d/mysql start
Mysql-u root-p
You can do it.
If MySQL is not turned off, you can only
Killall Msyqld.
The following is a multi-instance MySQL boot modify lost root password method
1. Turn off MySQL
Killall Msyqld
2. Add--skip-grant-tables parameter at startup
Mysqld_safe--defaults-file=/data/3306/my.cnf--skip-grant-table &
Mysql-uroot-p-s/data/3306/mysql.sock <== Login time-space password
3. Changing the password is the same as a single instance.
Retrieve the lost MySQL root user password