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.