mysql5.7 修改root密码无法登陆原因

升级的mysql5.7修改完root账户密码后仍然无法登陆,查阅资料可能和user表的plugin 字段为空有关。

1、首先将my.ini中加入在[mysqld]节点上加skip-grant-tables
主要作用是:跳过表中的验证,可以无密码登陆。

2、登录之后查询plugin字段值:

mysql> select plugin from user where user = 'root';

执行结果plugin字段为空。

3、更新plugin字段为mysql默认值:

mysql> update user set plugin='mysql_native_password';

查询更新结果:


4、更新成功,继续执行更新密码操作:

mysql> update user set authentication_string=password('123456') where user='root' and host='localhost';

5、刷新权限:

mysql> flush privileges;

6、将my.ini中的skip-grant-tables注释掉或者删掉

重启mysql,密码更新成功,亲测有效!

原地址:https://blog.csdn.net/xyajia/article/details/76746883

僵尸将臣
原文地址:https://www.cnblogs.com/sunshenggang/p/9400045.html