mysql 安装后第一次登录报ERROR 1862 (HY000) 密码过期问题

在多次安装mysql过程中发现,在centos6版本中,安装初始化mysql数据库后,第一登录即报:

ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
很是纳闷,密码还未使用就已经过期了,而且你越过权限表后,更改密码,正常登录依然报密码过期。在centos7 版本中就没有发现这个问题;

现总结该问题的解决方法:

1、 用忽略授权表的方法进入mysql 
 vi /etc/my.cnf

[mysqld]
skip-grant-tables

:wq! #保存退出 


2、重启mysql服务

#service mysql restart 

进入mysql,查看root用户的详细信息
# mysql -u root -p
> use mysql
> select * from mysql.user where user='root' \G 

*************************** 1. row ***************************

                  Host: localhost

                  User: root

           Select_priv: Y

           Insert_priv: Y

           Update_priv: Y

           Delete_priv: Y

           Create_priv: Y

             Drop_priv: Y

           Reload_priv: Y

         Shutdown_priv: Y

          Process_priv: Y

             File_priv: Y

            Grant_priv: Y

       References_priv: Y

            Index_priv: Y

            Alter_priv: Y

          Show_db_priv: Y

            Super_priv: Y

 Create_tmp_table_priv: Y

      Lock_tables_priv: Y

          Execute_priv: Y

       Repl_slave_priv: Y

      Repl_client_priv: Y

      Create_view_priv: Y

        Show_view_priv: Y

   Create_routine_priv: Y

    Alter_routine_priv: Y

      Create_user_priv: Y

            Event_priv: Y

          Trigger_priv: Y

Create_tablespace_priv: Y

              ssl_type:

            ssl_cipher:

           x509_issuer:

          x509_subject:

         max_questions: 0

           max_updates: 0

       max_connections: 0

  max_user_connections: 0

                plugin: mysql_native_password

 authentication_string: *AC241830FFDDC8943AB31CBD47D758E79F7953EA

      password_expired: Y

 password_last_changed: 2018-06-11 16:52:49

     password_lifetime: NULL

        account_locked: N

1 row in set (0.00 sec) 


3、把password_expired 改成不过期
>  update user set password_expired='N' where user='root';
> flush privileges;
> quit 

4、把 /etc/my.cnf 的 skip-grant-tables 这行注释掉

5、重启服务

#service mysql restart 

6、再次登陆 mysql 就正常了

猜你喜欢

转载自blog.csdn.net/shilukun/article/details/82663362
今日推荐