震惊!Linux下忘记mysql密码他竟这样做

  1. 打开mysql文件夹,找到/etc/my.cnf配置文件,在/etc/my.cnf末尾 加入skip-grant-tables,保存,跳过身份验证。
  2. 重启MySql,使刚才修改的配置生效。
  3. 终端输入mysql,然后再输入use mysql;
  4. 终端输入update mysql.user set authentication_string=password(‘123456’) where user=‘root’;
  5. 在/etc/my.cnf末尾 去掉skip-grant-tables,保存。
  6. 重启MySql,终端输入 mysql -u root -p ,然后根据提示输入刚设置的密码即可正常使用了。

猜你喜欢

转载自blog.csdn.net/mrliqifeng/article/details/71177419