1vim /etc/my.cnf,添加 skip-grant-table(跳过权限验证),注意是加在mysqld模块下;
重启mysql服务;
systemctl stop mysqld //停止mysql服务
systemctl restart mysqld //重启mysql
systemctl status mysqld //查看mysql服务状态
无密码登录;
mysql -u root -p
-- 查询一下安全模式开关
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 '123456';
alter user 'root'@'localhost' identified by '123456';
-- 上面两个二选一,具体参考下面,一一对应
select user, host from user;
flush privileges;
修改密码长度
show variables like 'validate%';
set global validate_password.length = 4;
set global validate_password.policy = LOW;
评论区