Recently, the root password of MySQL in the lab has been changed. You need to find a way to change the new password. The method is as follows:
1. Disable the MySQL service.
/Etc/init. d/mysqld stop
2. Use the-Skip-grant-tables option to start the MySQL service. You can add this option to the startup location of the/etc/inin. d/mysqld script,
VI/etc/init. d/mysqld
Add -- skip-grant-tables in the following statement to run the startup command.
/Usr/bin/mysqld_safe -- skip-grant-tables -- datadir = "$ datadir" -- socket = "$ socketfile "/
-- Log-error = "$ errlogfile" -- PID-file = "$ mypidfile "/
Adding -- skip-grant-tables means that the permission table authentication is skipped when the MySQL service is started. After MySQL is started, the root user connected to MySQL does not need a password.
3. Restart the MySQL service.
/Etc/init. d/mysqld start
4. Modify the password of the root user;
Mysql> Update mysql. User SET Password = PASSWORD ('000000') where user = root;
Mysql> flush privileges;
Mysql> quit
5. Restart MySQL to log on with the new password.
Mysql-u root-P
Enter Password 123456
6. Disable the MySQL service.
/Etc/init. d/mysqld stop
7. Modify the/etc/init. d/mysqld modified in step 1 to keep it unchanged. That is, cancel the -- skip-grant-tables statement.
8. Restart the MySQL service.
/etc/init.d/mysqld start