- 找到mysql.ini文件,在[mysqld]下边加上
skip-grant-tables
配置文件.png
-
添加后就忽略了密码验证,直接登录然后输入密码:mysql -u root -p
image.png - 修改root密码
update user set authentication_string=password('123456')
where user='root';
image.png
这里要注意的是 mysql5.7以前的密码字段是password,5.7用的是authencation_string字段,如果是5.7以前的版本,要改成
update user set password=password('123456')
where user='root';
- 修改成功后,把mysql.ini文件中的
skip-grant-tables
注视掉 - 重启mysql的服务
网友评论