mysql 忘记root密码

  1,编辑/etc/my.cnf

    添加:skip-grant-tables

  2,mysql -uroot -p

  进入mysql修改root密码:

  mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'redhat';

      ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

    这时候只需要:

  flush privileges

  就可以了。

原文地址:https://www.cnblogs.com/yangxiaochu/p/8268229.html