mysql5.7输入密码报错:Your password has expired

mysql报错:

[root@k8s-master ~]# mysql -uroot -h127.0.0.1 -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、修改 /etc/my.cnf,在 [mysqld] 添加:skip-grant-tables=1

2、重启 mysqld 服务:systemctl restart mysqld

3、使用 root 用户登录到 mysql:

mysql -uroot 
update mysql.user set password_expired='N' where user='root';
update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';
flush privileges;

4、注释掉:skip-grant-tables=1

5、重启 mysqld 服务:systemctl restart mysqld

6、修改密码:

mysql -uroot -p
alter user 'root'@'localhost' identified by '密码';
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;
posted @ 2021-12-18 19:30  1769987233  阅读(576)  评论(0编辑  收藏  举报