一、mysql -uroot -p
二、use mysql
三、修改密码
1、(无password字段的版本)
update user set authentication_string=PASSWORD("密码") where user='root';
2、(有password字段的版本)
update user set password=password('密码') where user='root';
四、这一步就是设置加密模式,修改了才会起到效果
update user set plugin="mysql_native_password";
五、刷新生效
flush privileges;
六、重启mysql服务 (有的刷新就可以了)
本文详细介绍了如何在MySQL中更改root用户的密码,包括无password字段和有password字段的两种情况,步骤涵盖从使用mysql命令行到刷新权限,以及可能需要的重启服务操作。
1561

被折叠的 条评论
为什么被折叠?



