mysql8.0的版本忘记密码

mysql8.0的版本;
出现错误:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES);

第一步:关闭 net stop mysql 这个需要cmd的管理员权限;
第二步:在安装MySQL的bin目录 执行 :mysqld --console --skip-grant-tables --shared-memory
第三步:启动一个新的cmd窗口 执行 mysql -uroot -p 就能免密进入
第四部修改密码:

  1. use mysql;
  2. update user set authentication_string='' where user='root';   //如果这个字段有值,先置为空
  3. flush privileges;     //刷新权限表
    4.ALTER user 'root'@'localhost' IDENTIFIED BY '123456';      //修改root 密码
    5.quit;     //退出mysql命令
    OK!
posted @ 2023-01-03 16:19  ALin_Da  阅读(20)  评论(0编辑  收藏  举报