MySQL数据库修改authentication_string字段为显示密码后无法登录

MySQL数据库修改authentication_string字段为显示密码后无法登录

1. 本文创作背景

本文介绍MySQL数据库修改authentication_string字段为显示密码后无法登录的处理办法。

2. 问题

用户通过navicat修改MySQL的user表root帐号的“authentication_string”字段,修改为为显示密码后无法登录客户端。
authentication_string

3. 原因分析

修改密码方式错误,不应直接改user表的authentication_string字段的hash key,需要通过控制台重置root密码方式修改。
错误修改密码方式案例:

update mysql.user set authentication_string = 'new_password' where user = 'root';

另外老版本mysql修改密码可以用以下代码,新版本mysql已经不支持PASSWORD函数。

update mysql.user set authentication_string = PASSWORD('new_password')  where user = 'root';

4. 解决方案

由于8.0版本不支持password函数,因此需要通过以下步骤恢复authentication_string :

找出帐号的authentication_string字段,看看其他用户的authentication_string,使用以下命令将authentication_string改回来

update mysql.user set authentication_string='XXX'  where user = 'root';

mysql

之后再用正确的改密方式重置root帐号密码。

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'XXX'; 
flush privileges;

修改后用户就可以正常登录root帐号。

5. 附录

  1. 查询mysql连接数量
  2. 解决pymysql不能实时查询最新的数据
  3. Linux中mysql的安装|配置|操作|卸载
  4. 联合索引、索引覆盖和索引下推详解
  5. PyMySQL 使用笔记
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值