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