忘记mysql root账号密码解决方式

忘记mysql密码无法登录

1、跳过检查方式启动mysql服务

service mysqld start --skip-grant-tables 或(systemctl start mysqld --skip-grant-tables)

2、无密码登录mysql

mysql -uroot

use mysql

3、设置新密码(我是5.7版本没有password字段,可以用desc user 查看密码字段)

update user set authentication_string=password('你的密码') where user='root';

4、退出重启MySQL服务

quit

service mysqld restart