mysql数据忘记库密码

忘记数据库密码

  • 1、/etc/my.cof文件中添加第一行 skip-grant-tables
  • 2、重启服务 systemctl restart mysqld
  • 3、mysql不需要密码直接登录
  • 4、修改密码 set password=password('123123');
  • 5、刷新 flush privileges;
  • 6、注释掉/etc/my.cof文件中添加的一行 #skip-grant-tables
  • 7、重启服务 systemctl restart mysqld

第二种方法

1、关闭数据库
2、启动数据库到维护模式
mysqld_safe --skip-grant-tables --skip-networking &
3、mysql 直接进入数据库
4、修改密码 alter user root@'localhost' identified by '1';
5、报错 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
6、 flush privileges;
7、再次修改密码  alter user root@'localhost' identified by '1';
8、退出 重新启动数据库

猜你喜欢

转载自www.cnblogs.com/jiangyatao/p/11008434.html