当前位置:   article > 正文

MYSQL删除匿名用户的方法_mysql5.7去掉匿名用户

mysql5.7去掉匿名用户
删除匿名用户

注:在老版本的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 7 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select user,host from mysql.user;  ← 查看用户信息
+------+----------------------------+  www.2cto.com  
| 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> delete from mysql.db where user='';
mysql> flush privileges;
mysql> select user,host from mysql.user;  ← 查看用户信息
+------+----------------------------+
| user | host         |
+------+----------------------------+
| root | localhost      |
| root | sample.centospub.com |
+------+----------------------------+
 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/985259
推荐阅读
相关标签
  

闽ICP备14008679号