Your password has expired. To log in you must change it using a client that supports expired passwor

本文提供两种解决MySQL5.7.14安装后因密码过期无法登录的问题方法。第一种涉及修改my.cnf文件,重启数据库,更新password_expired状态,再重启并修改密码;第二种使用Navicat直接修改user表中password_expired字段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mysql 5.7.14安装完后登陆报错,意思是密码过期

[root@mysql]# mysql -u root -p
Enter password: 
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.


第一种方法:解决办法:

1.在my.cnf  mysqld 部分加入 skip-grant-tables 参数。

[mysqld]
skip-grant-tables

2.重启mysql数据库,然后登陆

[root@llmj-mysql-40-115 tools]# mysql -u root -p
Enter password:   #这里直接回车,不需要密码即可登陆
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.14-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.=
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

3.查看mysql的用户状态

>select host,user,password_expired,account_locked from mysql.user;
+-----------+-----------+------------------+----------------+
| host      | user      | password_expired | account_locked |
+-----------+-----------+------------------+----------------+
| localhost | root      | Y                | N              |
| localhost | mysql.sys | N                | Y              |
+-----------+-----------+------------------+----------------+
3 rows in set (0.00 sec)

password_expired :y说明密码已经过期,可以改成N,就是未过期

>update mysql.user set password_expired='N';
Query OK, 1 row affected (0.03 sec)
Rows matched: 2  Changed: 1  Warnings: 0

4.然后注释掉skip-grant-tables参数

重启mysql,用过期的密码就可以登陆了,登陆之后可以用下面的命令修改密码
>alter user user() identified by '123456';
Query OK, 0 rows affected (0.03 sec)

>flush privileges;
Query OK, 0 rows affected (0.03 sec)
————————————————
版权声明:本文为优快云博主「zw_hard」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/zhengwei125/article/details/68486100

第二种方法:

这种方法是自己太懒了,直接用Navicat连接数据修改mysql数据库中user表password_expired这个字段值为‘N’,就可以了。

首先修改 my.cnf 文件跳过密码登录

vi etc/my.cnf

1.配置好后 按Esc退出vi编辑 :wq退出保存,

2. 重启mysql 

systemctl restart mysqld.service 

以上用的均是centos7命令,其他系统请注意....

3.Navicat直接连接 mysql数据库中user表password_expired这个字段值为‘N’,后返回来在吧my.cnf文件中配置  跳过登录的语句删除。重启MySQL就可以了。。。。哈哈哈哈!!!!!!!!!!机智

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值