首页 > 技术文章 > mysql 忘记root密码

yangxiaochu 2018-01-11 14:27 原文

  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

  就可以了。

推荐阅读