How to modify the password of MySQL in Centos

Source: Internet
Author: User

How to modify the password of MySQL in Centos

I just installed one on the VM a few days ago.MySQL5.7You can easily configure a password and forget it today. "), So I tried to paste the password change method in case that some friends forgot the password.
Disable MySQL first:

Service mysqld stop

Set the MySQL logon mode to logon without a password:

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

Then you can use it directly:Mysql-u rootLogged on to the database ~ After logging on to the database, modify and set the new password in the original data table. The Code is as follows:

Use mysql; UPDATE userSET Password = PASSWORD ('newpassword') where user = 'root'; flush privileges; quit;

In the above code snippetNEWPASSWORDReplace it with the new password you want to set. "flush privileges" is usedRefresh the system permission table to make the modification take effect.Of course, you can also directlyRestart the MySQL serverTo make the settings take effect.

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.