【无标题】Mysql8修改密码,不会出现烦人的1396Error

修改密码网上好多方法都报error 1396。可能是mysql8的原因吧?

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 'yourpassword';
alter user 'root'@'localhost' identified by 'yourpassword';
-- 上面两个二选一,具体参考下面,一一对应
select user, host from user;

附录:

-- 修改密码强度
show variables like 'validate%';
set global validate_password.length = 4;
set global validate_password.policy = LOW;
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值