linux 如何初始化密码(解决mysql root用户登录不了的问题)

这是我遇到的问题

 

 然后就想这可能是mysql安全模式的问题,解决思路:首先改变mysql的安全模式及密码校验问题,jinrumysql后在更改用户名密码。

1、首先将my.ini中加入在[mysqld]节点上加skip-grant-tables 也可能是my.cnf

主要作用是:跳过表中的验证,可以无密码登陆。

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,密码更新成功,亲测有效!

猜你喜欢

转载自www.cnblogs.com/kujiawei/p/11434318.html