MySQL跳过密码登录

第一种 
1.1停止mysql服务 
1.2以管理员身份运行cmd,执行以下命令

cd C:\Program Files\mysql-5.7.17-winx64\bin
mysqld --skip-grant-tables
或者
mysqld_safe
--skip-grant-tables

1.3在不关闭cmd情况下重新以管理员身份运行一个cmd,执行如下命令

cd C:\Program Files\mysql-5.7.17-winx64\bin
mysql -uroot -p
alter user 'root'@'localhost' identified by '123456';
flush privileges;

注:123456是设置root的新密码,C:\Program Files\mysql-5.7.17-winx64\bin是mysql的地址

第二种 
2.1MySQL配置文件my.ini中,在[mysqld]下添加skip-grant-tables 
2.2重启MySQL服务 
2.3用管理员身份进入cmd,输入如下命令

cd C:\Program Files\mysql-5.7.17-winx64\bin;
flush privileges;
alter user 'root'@'localhost' identified by '123456';

注:123456是设置root的新密码

posted @ 2017-09-23 14:53  Microtiger  阅读(12358)  评论(0编辑  收藏  举报