zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

mysql 5.7 登录时报:ERROR 1862 (HY000): Your password has expired

mysql Error 登录 HY000 has your 时报 password
2023-09-27 14:22:13 时间

一 问题描述

1.在项目现场,安装的是麒麟linux操作系统,安装完成mysql后,进行mysql 命令行登录时,报如下错误:

[root@localhost ~]# 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 服务:

service mysql stop

service mysql start

或者执行如下命令:

systemctl restart mysqld

3.使用 root 用户登录到 mysql: (没有密码,直接按回车键)

mysql -uroot   -p

进入myql的命令模式下,执行如下命令:

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、修改 /etc/my.cnf,注释掉:skip-grant-tables=1

5、重启 mysqld 服务:

service mysql stop

service mysql start

或者执行如下命令:

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;

7.再次登录

mysql -uroot -p root

进入之后:

mysql> set password=password('cloudiip123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'cloudiip123';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

[root@localhost etc]# service mysql stop
Shutting down MySQL.. SUCCESS! 
[root@localhost etc]# service mysql start
Starting MySQL. SUCCESS! 
[root@localhost etc]#