电脑上安装了Mysql,mysql数据库的版本5.7,时间太长之后,忘记了密码,网上的方法好像因为版本不同都没法解决,综合了几种解决方案之后,终于重置好密码,步骤如下:
1,,修改为免密登录,在windows中,修改my.ini,在mysqld中增加一行 skip-grant-tables
2.重启mysqld服务;
3.使用mysql -uroot 登录
4. 执行以下sql
use mysql;
update user set authentication_string=password("123456") where user="root";
flush privileges;
5. 执行完成,删除/注释a步骤中增加的那行启动参数;
6. 重启mysqld服务