mysql -p ERROR 1862 (HY000): Your password has expired.To log in you must change it using a ......

ERROR 1862 (HY000): Your password has expired.To log in you must change it using a client that supports expired passwords.

1. 超级用户登陆密码过期 无效

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

在这里插入图片描述

2. 故障解决方法

[root@server13 data]# /etc/init.d/mysqld stop  ##关闭mysqld进程
[root@server13 data]# rm -fr *
[root@server13 data]# ps -ef |grep mysql
[root@server13 data]# kill 2158
[root@server13 data]# ps -ef |grep mysql
root      2268 10382  0 17:49 pts/1    00:00:00 grep --color=auto mysql

在这里插入图片描述

[root@server13 data]# vim /etc/my.cnf
skip-networking  
skip-grant-tables  ##跳过权限认证

datadir=/usr/local/mysql/data
socket=/usr/local/mysql/data/mysql.sock
symbolic-links=0
[root@server13 data]# mysqld --initialize --user=mysql
[root@server13 data]# /etc/init.d/mysqld start
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 

在这里插入图片描述
新开一个cmd窗口,原来的别关,
输入命令:
mysql -uroot -p
出现:
Enter password:
在这里直接回车,不用输入密码。
然后就就会出现登录成功的信息。
然后在这里登SQLyog就可以登进去了

[root@server13 ~]# mysql -uroot -p
Enter password: 
MySQL [(none)]> use mysql;
MySQL [mysql]> UPDATE user SET `password_expired`='N' where user='root';   ##将密码过期修改为 密码不过期;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MySQL [mysql]> select * from mysql.user where user='root' \G; #查看数据
MySQL [mysql]> UPDATE user SET `authentication_string` = PASSWORD('root');  ##修改密码;
Query OK, 3 rows affected, 1 warning (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 1

MySQL [mysql]> flush privileges;  ##将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里;
Query OK, 0 rows affected (0.00 sec)

MySQL [mysql]> exit;

在这里插入图片描述
在这里插入图片描述

[root@server13 data]# mysql -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.31 Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MySQL [(none)]> ALTER USER root@localhost identified by 'westos';
Query OK, 0 rows affected (0.00 sec)  ##修改密码

在这里插入图片描述

密码更改后注释skip-grant-tables、skip-networking 使用修改后的密码重启mysql

[root@server13 data]# vim /etc/my.cnf
#skip-networking  
#skip-grant-tables

datadir=/usr/local/mysql/data
socket=/usr/local/mysql/data/mysql.sock
symbolic-links=0
[root@server13 data]# /etc/init.d/mysqld restart

在这里插入图片描述

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值