Mysql 数据库ERROR 1820 (HY000): You must reset your password using ALTER USER 解决办法

Mysql 5.7数据库原来一直都能正常访问,突然访问不了,查看日志提示数据库需要修改密码,

具体解决办法如下操作:

Windows 下:

mysql的bin目录下,

mysql>use mysql;

mysql>mysql -uroot -p密码;

判断“password_expired”是否为Y

mysql> select authentication_string,password_expired from user where user='root';

判断“default_password_lifetime”是否为0

mysql> show VARIABLES like "%password%";

“password_expired”为Y的解决方法

修改“password_expired”的值:

update user set authenticatio_string=password('123456'),password_expired='N' where user='root';

“default_password_lifetime”为0解决方法

修改“default_password_lifetime”的值:

mysql> set GLOBAL default_password_lifetime=0;

重启mysql:

net restart mysqld

Linux下:

1、查找问题
1.1、跳过数据库权限验证:

vim /etc/my.cnf

在my.cnf文件最后添加skip-grant-tables并保存

1.2、重启mysql:

sudo systemctl restart mysqld
mysql> use mysql;

1.3、判断“password_expired”是否为Y

mysql> select authentication_string,password_expired from user where user='root';

1.4、判断“default_password_lifetime”是否为0

mysql> show VARIABLES like "%password%";

2、“password_expired”为Y的解决方法
2.1、修改“password_expired”的值:

update user set authenticatio_string=password('123456'),password_expired='N' where user='root';​

2.2、恢复数据库权限验证:

vim /etc/my.cnf


在my.cnf文件最后去掉skip-grant-tables并保存

2.3、重启mysql:

sudo systemctl restart mysqld

3、“default_password_lifetime”为0解决方法
3.1、修改“default_password_lifetime”的值:

mysql> set GLOBAL default_password_lifetime=0;


3.2、恢复数据库权限验证:

vim /etc/my.cnf

在my.cnf文件最后去掉skip-grant-tables并保存

3.3、重启mysql:

sudo systemctl restart mysqld

原文链接:https://blog.csdn.net/shirenkan/article/details/105321160

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值