>  기사  >  데이터 베이스  >  删除MySQL匿名用户

删除MySQL匿名用户

WBOY
WBOY원래의
2016-06-07 17:30:231014검색

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

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.