MySQL删除匿名用户
  在 数据库 分类下   5 条评论

MySQL删除匿名用户

  在 数据库 分类下   5 条评论

MySQL删除匿名用户

在MySQL刚刚被安装后,存在用户名、密码为空的用户。这使得数据库服务器有无需密码被登录的可能性。为消除隐患,将匿名用户删除。

[root@sample ~]# mysql -u root -p  ← 通过密码用root登录
Enter password:  ← 在这里输入密码

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1402
Server version: 5.5.56-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

输入代码查看用户信息。

mysql> select user,host from mysql.user;
+------+----------------------------+ 
| user | host         |
+------+----------------------------+
|   | localhost       |
| root | localhost       |
|   | sample.centospub.com |
| root | sample.centospub.com  |
+------+----------------------------+
4 rows in set (0.02 sec)

执行语句,删除匿名用户

mysql> delete from mysql.user where user='';  ← 删除匿名用户
Query OK, 2 rows affected (0.17 sec)

查看用户信息

mysql> select user,host from mysql.user;
+------+----------------------------+
| user | host         |
+------+----------------------------+
| root | localhost      |
| root | sample.centospub.com |
+------+----------------------------+

匿名用户已删除

评论已关闭
  1. 来自北七家滞留孩子的给你的一份问候....

    1. @北七家滞留儿童

      留守儿童可以啊,很勤劳。

      1. @admin

        icon_twisted.gif 肯定的,你这博客挺好看,我到时候高仿一个

        1. @北七家滞留儿童

          我直接把程序给你不就完了 icon_cool.gif icon_cool.gif

          1. @admin

            也好 哈哈 但是你肯定还有需要完善的地方,你慢慢完善,完善好了我再跟你要