Home  >  Article  >  Database  >  删除MySQL匿名用户

删除MySQL匿名用户

WBOY
WBOYOriginal
2016-06-07 17:30:231015browse

今天安装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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn