基本使用类 mysql usdhsjkdshk h127.0.0.1 P3306 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 40Server version: 8.0.22debug Source distribution Copyright (c) 2000, 2020, 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> 功能性危害 当存在空用户时,可能因为匹配出错,导致正常的用户名无法登录。 示例:存在空用户与root用户的host有重叠时,导致root用户无法使用密码登录,或者使用空用户的密码登录后无法进入root的权限。 mysql> create user ''@'localhost'; Query OK, 0 rows affected (8.87 sec) mysql> select user,host from mysql.user; ++ user host ++ root % localhost mysql.infoschema localhost mysql.session localhost mysql.sys localhost ++ 用root的密码无法登录 mysql uroot h127.0.0.1 P3306 pTestroot mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 用空用户的密码(免密)登录后实际是空用户登录,没有root权限。 mysql uroot h127.0.0.1 P3306 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 45Server version: 8.0.22debug Source distribution Copyright (c) 2000, 2020, 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> select user,host from mysql.user; ERROR 1142 (42000): SELECT command denied to user ''@'localhost' for table 'user'