在 Arch Linux 上使用 MySQL 5.5,当我使用密码创建一个 localhost 用户并将所有表的所有权限授予它然后删除该用户时,我仍然可以以该用户身份登录而无需输入密码。
重现步骤:
# mysql -u root -h localhost -p
Enter password: <root password>
mysql> create user 'test'@'localhost' identified by 'testing123';
mysql> grant all on *.* to 'test'@'localhost' identified by 'testing123';
mysql> select * from mysql.user where user='test';
1 row in set (0.00 sec)
mysql> exit
# mysql -u test -h localhost -p
Enter password: testing123
mysql> show databases;
mysql> exit
# mysql -u root -h localhost -p
Enter password: <root password>
mysql> delete from mysql.user where user='test';
Query OK, 1 row affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
mysql> select * from mysql.user where user='test';
Empty set (0.00 sec)
mysql> exit
# mysql -u test -h localhost
mysql> (Why?)
不仅如此,“不存在的”测试用户仍然可以行使所有相同的权限。重大安全问题。如果我重新启动服务器,它仍然可以让我在没有密码的情况下登录。