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;