2019-05-16mysql忘记密码怎么办

windows下控制台

配置MySQL path环境

1、把mysql的 截止到bin路径 配置到 path 里面

2、打开cmd控制台

3、停止MySQL服务:net stop mysql56(服务名称)

4、修改my.ini文件   增加 skip-grant-tables

5、启动MySQL服务: net start mysql56(服务名称)

6、打开控制台 输入 mysql -u root 登录成功 修改密码

7、MySQL5.7版本 及以下:

 update  user set  password=password("123") where user="root";

 update mysql.user set password='123'  where user='test';

 MySQL5.8版本及以上 :

 alter user  'root'@'%'  indentified with mysql_native_password  by  'Root12345678@';

8、flush privileges;

centos下MySQL 忘记密码

 修改my.cnf 文件 :vim  /etc/my.cnf

在 mysqld 下 增加 一行 skip-grant-tables

登录 修改密码同上;

原文地址:https://www.cnblogs.com/wbly2019/p/10875224.html