How to deal with mysql5.7 forgetting root password under CentOS7

1.vi /etc/my.cnf 2.Add skip-grant-tables
in [mysqld] For example: [mysqld] skip-grant-tables datadir=/var/lib/MySQL socket=/var/lib/mysql/mysql .sock 3. Restart mysql service mysql restart 4. The user logs in mysql without password -uroot -p (click Enter directly, the password is empty) 5. Select the database use mysql; 6. Modify the root password update user set authentication_string=password(' 123456') where user='root'; 7. Execute flush privileges; 8. Exit exit; 9. Delete skip-grant-tables 10. Restart mysql service mysql restart


































Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326227378&siteId=291194637