0
点赞
收藏
分享

微信扫一扫

mysql8.0报错ERROR 1396 (HY000): Operation ALTER USER failed for ‘root‘@‘localhost‘

清冷的蓝天天 2022-01-22 阅读 44

网上找了一堆复制粘贴,一点卵用都没有的文章。
无论怎么操作都是报错如下:

ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'

这里有几个关键命令,最主要就是关闭安全模式

-- 查询一下安全模式开关
show variables like 'sql_safe_updates';
-- 关闭安全模式
set sql_safe_updates = 0;
-- 关闭安全模式下,才可以执行authentication_string为空
update user set authentication_string='' where user='root';
-- authentication_string空了的情况下,才可以真正修改密码
-- 刷新权限表
flush privileges;
-- 修改密码
alter user 'root'@'%' identified by 'S32*sdf312@';
alter user 'root'@'localhost' identified by 'S32*sdf312@';
-- 上面两个二选一,具体参考下面,一一对应
select user, host from user;

附录:

-- 修改密码强度
show variables like 'validate%';
set global validate_password.length = 4;
set global validate_password.policy = LOW;
举报

相关推荐

0 条评论