MySQL forgot password modification method under CentOS

Source: Internet
Author: User
Tags mysql login

Just a few days ago in the virtual host installed a MySQL5.7, conveniently configured a password, today directly forget (embarrassing face). "), so think about the way to change the password to paste it, in case a friend forgot the password to spare.
Turn off MySQL First:

Service Mysqld Stop

Set the MySQL login mode to login without a password:

Mysql_safe--user=mysql--skip-grant-tables-skip-networking &

Then you can directly use: mysql -u root log in to the database ~ after logging in to the database, the original data table to modify the setting of the new password, the code is as follows:

Use MySQL; UPDATE userset Password=password (' NewPassword ') where user= ' root '; FLUSH Privileges;quit;

 NEWPASSWORD   Replace with the new password you want to set, "FLUSH privileges" is used to   refresh the system permissions related tables for the changes to take effect   Of course, you can also directly   restart MySQL server   To make the settings effective.


MySQL forgot password modification method under CentOS

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.