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


    一 问题描述

    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的命令模式下,执行如下命令:

    1. update mysql.user set password_expired='N' where user='root';
    2. update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';
    3. 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]# 
     

  • 相关阅读:
    ES增删改查入门
    【深度学习 Pytorch笔记 B站刘二大人 线性模型 Linear-Model 数学原理分析以及源码实现(1/10)】
    【TypeScript】深入学习TypeScript装饰器
    keepalived+nginx高可用 脑裂监控
    FTP服务初探
    操作系统:文件IO
    使用stream流合并多个List(根据实体类特定属性合并)
    nginx快速入门
    【PTA-训练day7】L2-019 悄悄关注 + L1-027 出租
    ICS TRIPLEX T9402 自动化控制模块
  • 原文地址:https://blog.csdn.net/u011066470/article/details/126461960