1. First verify that the server is in a secure state, that is, no one can connect to the MySQL database arbitrarily. Because the MySQL database is completely out of password-protected state during the reset of the root password of MySQL, other users can log in and modify the MySQL information arbitrarily. It is possible to implement the server's quasi-security state by enclosing MySQL's external ports and stopping Apache and all user processes. The safest state is to operate on the console of the server and unplug the network cable.
2. To modify the login settings for MySQL:
In the paragraph [mysqld], add one sentence:
For example:
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock Skip
Save and Exit VI.
3. Restart Mysqld
#/etc/init.d/
4. Log in and modify the root password of MySQL
#/usr/bin/MySQL Welcome to the MySQL monitor. Commands End With; or \g. Your MySQL Connection ID is3 to Server version:3.23.56Type' Help; ' or ' \h ' forHelp. Type ' \c 'To clear the buffer. mysql>Use MySQL; Reading Table Information forCompletion of table and column names you can turn off Thisfeature to get a quicker startup with-A Database changed MySQL> UPDATE user SET Password = Password (' New-password ') WHERE user = ' root ' ; Query OK,0 Rows Affected (0.00sec) Rows matched:2 changed:0 warnings:0MySQL>flush Privileges; Query OK,0 rows affected (0.01sec) MySQL>quit Bye
5. Change MySQL login settings back
Delete the skip-grant-tables you just added in the paragraph [mysqld]
Save and Exit VI.
6. Restart Mysqld
#/etc/init.d/ for love!
Linux under the root password of MySQL forgot to solve the party