mysql 8.0.11 資料庫使用者密碼修改詭異的限制
近期,協助一客戶重置mysql 8.0.11的root密碼,碰到了奇怪的問題。
作業系統版本:rhel 7.6
資料庫版本:mysql 8.0.11
根據mysql 8.0官方文件說明,mysql的使用者密碼有限制,並且被硬編碼,沒有明確說明密碼長度是多少。
The MySQL user name length limit is hardcoded in MySQL servers and clients, and trying to circumvent it by modifying the definitions of the tables in the
mysql
database
does not work.
You should never alter the structure of tables in the
mysql
database in any manner whatsoever except by means of the procedure that is described in
Section 2.11, “Upgrading MySQL”. Attempting to redefine MySQL's system tables in any other fashion results in undefined and unsupported behavior. The server is free to ignore rows that become malformed as a result of such modifications.
另外,mysql 8.0不再支援password()函式,因此,不能像mysql5.x那樣通過update mysql.user表來修改使用者密碼。
但是,在mysql 8.0的root密碼重置時遇到報錯:
[mysql@mysql8~]$ mysql -uroot -p -S /home/mysql/mysql/tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
--update mysql.user重置使用者密碼失敗
mysql> update user set authentication_string = '123456' where user='root' and host='%' ;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> select user,host,authentication_string from mysql.user;
+------------------+-----------+------------------------------------------------------------------------+
| user | host | authentication_string |
+------------------+-----------+------------------------------------------------------------------------+
| root | % | 123456 |
| mysql.infoschema | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+------------------+-----------+------------------------------------------------------------------------+
5 rows in set (0.00 sec)
--password函式不被mysql8.0支援
mysql> update user set authentication_string =PASSWORD('123456') where user='root' and host='%' ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('
123456') where user='root' and host='%'' at line 1
mysql>
--奇怪的是使用alter命令重置root密碼長度為6位時報錯,但是不是語法錯誤
mysql> alter user 'root'@'%' identified by '123456'; ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%' --但是,將root密碼長度增加到8位時獲得成功
mysql> ALTER USER root IDENTIFIED WITH mysql_native_password BY '123456789';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,authentication_string from mysql.user;
+------------------+-----------+------------------------------------------------------------------------+
| user | host | authentication_string |
+------------------+-----------+------------------------------------------------------------------------+
| root | % | *CC67043C7BCFF5EEA5566BD9B1F3C74FD9A5CF5D |
| mysql.infoschema | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+------------------+-----------+------------------------------------------------------------------------+
5 rows in set (0.00 sec)
但是,我本地的centos 7.6上的mysql 8.0重置root密碼缺沒有密碼長度限制,兩套庫用的是相同的引數檔案。
官方關於使用者密碼長度沒有特別說明,網上也沒有類似密碼長度問題的資料,很奇怪!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29357786/viewspace-2704307/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql 8.0.11 以上版本修改root密碼MySql密碼
- 修改MySQL資料庫使用者密碼方法大全總結MySql資料庫密碼
- MongoDB 資料庫安全之使用者密碼修改MongoDB資料庫密碼
- Oracle 限制業務使用者自身修改密碼Oracle密碼
- MySQL資料庫中修改密碼方法總結(轉)MySql資料庫密碼
- 修改MySQL的root使用者的密碼MySql密碼
- mysql修改使用者密碼MySql密碼
- MySql中新增使用者,新建資料庫,使用者授權,刪除使用者,修改密碼MySql資料庫密碼
- mysql如何修改root使用者的密碼MySql密碼
- mysql修改資料庫編碼MySql資料庫
- MySQL 資料庫重置密碼MySql資料庫密碼
- MySQL修改使用者密碼及重置root密碼MySql密碼
- 忘記oracle的sys密碼該如何重置;附如何修改oracle資料庫使用者密碼Oracle密碼資料庫
- 修改mysql的root使用者密碼為空MySql密碼
- mysql 忘記密碼,mysql修改密碼MySql密碼
- mysql8.0+修改使用者密碼MySql密碼
- mongodb怎樣給本地資料庫新增使用者名稱密碼和修改賬號密碼?MongoDB資料庫密碼
- 修改mysql的root密碼MySql密碼
- 修改mysql資料庫的預設編碼方式MySql資料庫
- mysql 修改資料庫的列MySql資料庫
- mysql修改root密碼MySql密碼
- 修改mysql root密碼MySql密碼
- Centos7 修改mysql指定使用者的密碼CentOSMySql密碼
- wordpress修改繫結的mysql使用者名稱密碼MySql密碼
- 使用FNDCPASS修改EBS中資料庫和應用使用者的密碼資料庫密碼
- 修改Mysql root密碼的方法MySql密碼
- dede 忘記密碼在資料庫中修改方法密碼資料庫
- phpmyadmin匯入資料庫大小限制修改PHP資料庫
- [zt] 使用FNDCPASS修改EBS中資料庫和應用使用者的密碼資料庫密碼
- 關於MySQL下修改root使用者密碼的解決MySql密碼
- MySQL新建使用者,授權,刪除使用者,修改密碼MySql密碼
- mysql8.0修改密碼MySql密碼
- 修改 MySQL 登入密碼MySql密碼
- mysql修改管理員密碼MySql密碼
- MYSQL修改密碼和忘記ROOT密碼MySql密碼
- 修改git使用者密碼Git密碼
- MySql修改資料庫編碼為UTF8MySql資料庫
- mysql 資料庫 表 欄位 編碼修改 方法MySql資料庫