码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2019-08-30 14:23:58      阅读:349      评论:0      收藏:0      [点我收藏+]

标签:jin   use   img   成功   ati   ica   word   localhost   nat   

这是我遇到的问题

技术图片 

 然后就想这可能是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,密码更新成功,亲测有效!
技术图片

 

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

标签:jin   use   img   成功   ati   ica   word   localhost   nat   

原文地址:https://www.cnblogs.com/kujiawei/p/11434318.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!