侧边栏壁纸
博主头像
会飞的大象博主等级

爱运动的程序猿

  • 累计撰写 126 篇文章
  • 累计创建 158 个标签
  • 累计收到 0 条评论
标签搜索

目 录CONTENT

文章目录

mysql8.0忘记roo密码

会飞的大象
2022-10-08 / 0 评论 / 0 点赞 / 731 阅读 / 230 字

1vim /etc/my.cnf,添加 skip-grant-table(跳过权限验证),注意是加在mysqld模块下;

image

重启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;
0

评论区