linux下mysql8版本修改登录密码
包括报错
mysql8.0报错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;
查询对应的host
select user, host from user;
选择其中一个;“%” 这个位置对应的是host的值
-- 修改密码 alter user 'root'@'%' identified by 'S32*sdf312@'; alter user 'root'@'localhost' identified by 'S32*sdf312@';