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
![](http://dl2.iteye.com/upload/attachment/0124/5545/85dc0f8b-ffb3-3229-a97d-2053631b7e1c.png)
![](http://dl2.iteye.com/upload/attachment/0124/5547/8cfa4a88-bef3-35a4-8764-50b2d541148e.png)