本地 MySQL 忘记 root 密码怎么救

步骤

  1. 管理员 CMD 停服务:net stop MySQL80
  2. 跳过授权表启动:mysqld --console --skip-grant-tables --shared-memory
  3. 另开窗口无密码登录:mysql -u root
  4. 改密:ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

MySQL 8 必须带 --shared-memory 才能本地无密码连上。

← 返回博客列表