windows:
1、先停止mysql
net stop mysql57
2、修改my.ini
增加 skip-grant-tables 参数
3、启动mysql
net start mysql57
使用cmd 命令窗口。
执行 mysql -uroot -p
提示输入密码,直接回车即可进入 mysql 命令窗口。
执行
mysql > update mysql.user set password=password('123456') where user='root';
5.7版本
update mysql.user set authentication_string=password('123'), password_expired = 'N', password_last_changed = now() where user='root' and Host = 'localhost';
再执行 alter
user
'root'
@
'localhost'
identified
by
'123'
;
4、去掉my.ini 中的 skip-grant-tables 参数 ,重启mysql 即可。