当前位置:Gxlcms > mysql > 删除MySQL匿名用户

删除MySQL匿名用户

时间:2021-07-01 10:21:17 帮助过:32人阅读

今天安装MySQL-5.1.62后,登陆进去查看用户,发现有四个 mysqlgt; select user,host from user;+------+--------------+| user

今天安装MySQL-5.1.62后,登陆进去查看用户,,发现有四个

mysql> select user,host from user;
+------+--------------+
| user | host |
+------+--------------+
| | MySQL-Server |
| root | MySQL-Server |
| | localhost |
| root | localhost |
+------+--------------+
4 rows in set (0.00 sec)

其中两个看不到用户名,通过正常的drop user无法删除
drop user ""@localhost
drop user ""@"MySQL-Server"
结果还是可以看得到,并没有被删除。


后来想到个方法,就是直接删除这个表的内容
mysql> delete from user where user='';
Query OK, 2 rows affected (0.01 sec)


mysql> select user,host from user;
+------+--------------+
| user | host |
+------+--------------+
| root | MySQL-Server |
| root | localhost |
+------+--------------+
2 rows in set (0.00 sec)


mysql> delete from user where host="MySQL-Server";
Query OK, 1 row affected (0.00 sec)


mysql> select user,host from user;
+------+-----------+
| user | host |
+------+-----------+
| root | localhost |
+------+-----------+
1 row in set (0.00 sec)


最后再刷新下就好了。
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

相关阅读:

增加MySQL用户

MySQL用户管理

Linux下 MySQL 用户的管理

linux

人气教程排行