mysql5.7 root password forgotten after password change

Source: Internet
Author: User
Tags mysql command line

First, change the my.cnf configuration file

1. Edit the/etc/my.cnf configuration file with the command, namely: VIM/ETC/MY.CNF or VI/ETC/MY.CNF

2. Add skip-grant-tables under [mysqld], then save and exit

3. Restart MySQL Services: Service mysqld restart

Second, change the root user name

1. After reboot, execute MySQL command to enter MySQL command line

2. Change the root user password

mysql> updatemysql.user set authentication_string=password(‘123qwe‘) where user=‘root‘ andHost = ‘localhost‘;

mysql> flush  privileges ; mysql> quit;

* Note that there is no password field in the user table in the new MySQL database.

Instead, the encrypted user password is stored in the Authentication_string field

3. Use the Systemctl Stop Mysqld.service command to turn off the MySQL service. 4. Comment out the skip-grant-tables you just added in the/etc/my.cnf file using # 5. Restart the MySQL service using the systemctl start Mysqld.service command.

mysql5.7 root password forgotten after password change

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.