之前在Mysql5.7 安装的时候提到了配置文件中的 skip-grant-tables 。
skip-grant-tables 该方式指定启动mysql时不启动grant-tables,授权表。
修改配置文件
在my.ini 配置文件中添加 skip-grant-tables
重启mysql服务
-
使用命令
net stop mysql net start mysql -
使用window 服务管理器,右键点击重新启动
连接MySQL服务
只输入mysql
mysql
输入mysql- uroot -p不输入密码
mysql -uroot -p
修改密码
set password for '用户名'@'主机' = password('新密码');
修改密码可能会报错
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
输入
flush privileges;
再设置密码就可以了