mysql5.7.初始化后,临时密码过期

摘要:
安装mysql5.7遇到一个特别纠结的问题,初始化成功之后,使用临时密码提示过期。

安装mysql 5.7遇到一个特别纠结的问题,初始化成功之后,使用临时密码提示过期。反复初始化n次,还是临时密码过期。脑袋很大。下面贴出代码

[root@oracle11g data]# mysqld --initialize --user=mysql
[root@oracle11g data]# service mysqld start
Starting MySQL.. SUCCESS![root@oracle11g data]# cat error.log 
2020-01-14T10:07:56.315349+08:00 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore detail
s). 100
 100
 100
 100
2020-01-14T10:08:11.771346+08:00 0 [Warning] InnoDB: New log files created, LSN=45790
2020-01-14T10:08:11.883164+08:00 0[Warning] InnoDB: Creating foreign key constraint system tables.
2020-01-14T10:08:11.960205+08:00 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: b76a7b2a-3672-11ea-9a85-080027651e78.2020-01-14T10:08:11.962281+08:00 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed'cannot be opened.
2020-01-14T10:08:11.965106+08:00 1 [Note] A temporary password is generated for root@localhost: Ei5PJ#K./fn-

登录mysql使用临时密码,这个过程我疑惑了好久,明明是刚初始化成功的,立马使用临时密码进行登录也不可以,提示密码过期

[root@oracle11g data]# mysql -uroot -p"Ei5PJ#K./fn-"ERROR 1862 (HY000): Your password has expired. To log in you must change it usinga client that supports expired passwords.
[root@oracle11g data]# 

采用跳过密码验证,编辑/etc/my.cnf文件

[mysqld]
skip-grant-tables

重启mysql,使用免密码登录数据库,修改密码的时候提示mysql服务使用--skip-grant-tables,不能执行修改密码操作

[root@oracle11g data]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.7.25-log MySQL Community Server (GPL)

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

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

root@localhost [(none)]>alter user 'root'@'localhost' identified by '123456';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
root@localhost [(none)]>

修改系统表,临时密码不过期

root@localhost [(none)]>use mysql
Reading table information forcompletion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

root@localhost [mysql]>select * from 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: 0max_updates: 0max_connections: 0max_user_connections: 0plugin: mysql_native_password
 authentication_string: *7C9CB2A4F227FF764C10705941B03E2B1C378AF1
      password_expired: Y
 password_last_changed: 2020-01-14 10:08:12password_lifetime: NULL
        account_locked: N
1 row in set (0.00sec)

ERROR: No query specified

root@localhost [mysql]>update user set password_expired='N' where user='root';
Query OK, 1 row affected (0.09sec)
Rows matched: 1  Changed: 1  Warnings: 0
root@localhost [mysql]>select * from 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: 0max_updates: 0max_connections: 0max_user_connections: 0plugin: mysql_native_password
 authentication_string: *7C9CB2A4F227FF764C10705941B03E2B1C378AF1
      password_expired: N
 password_last_changed: 2020-01-14 10:08:12password_lifetime: NULL
        account_locked: N
1 row in set (0.00sec)

ERROR: No query specified

修改/etc/my.cnf,删除--skip-grant-tables,重新启动mysql

[root@oracle11g data]# service mysqld restart
Shutting down MySQL.. SUCCESS!Starting MySQL.. SUCCESS![root@oracle11g data]# 

[root@oracle11g data]# mysql -uroot -p"Ei5PJ#K./fn-"Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MySQL connection id is 2Server version: 5.7.25-log MySQL Community Server (GPL)

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

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

root@localhost [(none)]>

修改mysql root密码

root@localhost [(none)]>alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01sec)

root@localhost [(none)]>flush privileges;
Query OK, 0 rows affected (0.10 sec)

退出登录,使用新密码进行登录

[root@oracle11g data]# mysql -uroot -p"123456"Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MySQL connection id is 3Server version: 5.7.25-log MySQL Community Server (GPL)

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

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

root@localhost [(none)]>

免责声明:文章转载自《mysql5.7.初始化后,临时密码过期》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇oracle rac 添加SCAN IP如何学好VC和MFC(各前辈学习方法及感受整理)(三)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

centos6.5安装mysql5.7.20

CentOS 通过yum在线安装MySQL5.7 Step1: 检测系统是否自带安装mysql # yum list installed | grep mysql Step2: 删除系统自带的mysql及其依赖命令: # yum -y remove mysql-libs.x86_64 Step3: 给CentOS添加rpm源,并且选择较新的源命令: #...

sqoop迁移

3.1 概述 sqoop是apache旗下一款“Hadoop和关系数据库服务器之间传送数据”的工具。 导入数据:MySQL,Oracle导入数据到Hadoop的HDFS、HIVE、HBASE等数据存储系统; 导出数据:从Hadoop的文件系统中导出数据到关系数据库 3.2 工作机制 将导入或导出命令翻译成mapreduce程序来实现 在翻译出的mapre...

iOS 架构-App组件化开发

前因 其实我们这个7人iOS开发团队并不适合组件化开发。原因是因为性价比低,需要花很多时间和经历去做这件事,带来的收益并不能彻底改变什么。但是因为有2~3个星期的空档期,并不是很忙;另外是可以用在一个全新的App上。所以决定想尝试下组件化开发。 所谓尝试也就是说:去尝试解决组件化开发当中的一些问题。如果能解决,并且有比较好的解决方案,那就继续下去,否则就...

Qt5.9.1结合REF开发基于chorm的浏览器(二)

将libcef_dll_wrapper编译方式设置为MD 因为使用的Qt是动态链接的,而cef模式使用的是静态链接的方式,所以在使用前需要将cef编译方式改成Multi-thread DLL(/MD),修改路径在在C/C++->Code Generation下的Runtime Library。重新编译后的libcef_dll_wrapper.lib库...

Prometheus+Grafana监控mysql主从故障告警

因业务需求,mysql主从常常出现同步故障,故研究了Prometheus来做mysql主从同步状态监控报警。 1 Prometheus介绍 1.1什么是Prometheus? Prometheus是由SoundCloud开发的开源监控报警系统和时序列数据库(TSDB)。Prometheus使用Go语言开发,是Google BorgMon监控系统的开源版本。...

CentOS6.5卸载默认安装的mysql5.1,并安装mysql5.5(亲测有效)

感谢链接:https://jingyan.baidu.com/article/922554465e471a851648f4ed.html 指导。 1、安装前:CentOS6.5 yum 安装MySQL是5.1版本。老板觉得低了,好=》卸载,装上5.5的。 2、最终效果图:命令 select version(); 3、不废话,上代码和步骤: 第一步就是看l...