Mysql5.7 method to reset the password: First execute the [update user set authentication_string = password('123456') where user = 'root';] statement; then restart the mysql service.
Specific method:
(Recommended tutorial: mysql video tutorial)
Close MySQL5. 7 permission system
Find the configuration file my.cnf of MySQL5.7
Edit and add the code skip-grant-tables at the end of the file
Restart the mysqld service and log in to MySQL
$systemctl restart mysqld
When you log in to mysql at this time, you can log in without a password.
Modify root password
$use mysql; $select host,user,authentication_string from user; #修改root密码 $update user set authentication_string = password('123456') where user = 'root';
Enable the permission system, restart MySQL, and log in with a new password
$vim /etc/my.cnf #开启权限系统 #skip-grant-tables #重启mysql $systemctl restart mysqld #新root密码登陆 $mysql -uroot -p
Related recommendations: mysql tutorial
The above is the detailed content of How to reset password in mysql5.7. For more information, please follow other related articles on the PHP Chinese website!