CentOS 7.2 mysql root password forgotten when reset method

Source: Internet
Author: User

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.

To modify the login settings for MySQL:

Add a sentence to the paragraph in [mysqld]: Skip-grant-tables

Vim/etc/my.cnf

Join Skip-grant-tables

Restart Mysqld

Systemctl Stop Mysqld

Systemctl Start mysqld

Log in to MySQL (direct enter, no password required)

mysql> use MySQL;

mysql> Update user Set Password=password ("test") where user= ' root ';

mysql> flush Privileges;

Exit

Restart Mysqld again

Systemctl Stop Mysqld

Systemctl Start mysqld

Log in with a new password, log in normally


CentOS 7.2 mysql root password forgotten when reset method

Related Article

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.