Linux under the root password of MySQL forgot to solve the party

Source: Internet
Author: User
Tags mysql login

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.