当先锋百科网

首页 1 2 3 4 5 6 7

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

相关阅读:

0b1331709591d260c1c78e86d0c51c18.png