說明:
安裝Mysql 5.7.17 登錄root 用戶使用初始化密碼提示如下錯誤:
[root@dg1 bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2017-09-15T17:02:21.325100Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-15T17:02:21.340179Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2017-09-15T17:02:21.340188Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2017-09-15T17:02:21.607826Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-09-15T17:02:21.694184Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-09-15T17:02:21.767894Z 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: a3a83820-9a37-11e7-974b-08002756e36d.
2017-09-15T17:02:21.771093Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-09-15T17:02:21.771983Z 1 [Note] A temporary password is generated for root@localhost: xqIejk1p1H:l
[root@dg1 bin]# mysql -u root -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
解決方法:
一般安裝mysql 目錄 /usr/local/mysql 使用絕對路徑登錄
[root@dg1 bin]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 5
Server version: 5.7.17
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql>
原因分析:
安裝Linux 操作系統的時候,默認安裝了mysql,並且版本與自己安裝的mysql版本不一致,直接使用mysql -uroot -p‘password‘連接,默認調用的是系統安裝的mysql版本,所以會提示密碼過期。可以通過指定mysql的絕對路徑或者拷貝新安裝的mysql客戶端到系統路徑下解決此問題。