net stop mysql停止mysql服务
mysqld --console --skip-grant-tables --shared-memory跳过Mysql的密码认证
mysql -u root -p无密码登录.注意,之前打开的cmd窗口不能关闭
use mysql;
-- 将root用户的密码置为空
update user set authentication_string = '' where user = 'root';
quit;


net start mysql打开mysql服务,然后输入输入mysql -u root -p无密码登录
use mysql;
-- 查询root用户的host
select user,host from user where user = 'root';
-- 修改密码
ALTER USER 'root'@'%' IDENTIFIED BY '新密码';
-- 刷新权限
flush privileges;
-- 退出登录
quit;

