[英]Drop user without a name from sql database
Executing the following command执行以下命令
MariaDB [(none)]> select distinct user from mysql.user;
results in结果是
+-------------+
| User |
+-------------+
| app_user |
| |
| test_u |
| mariadb.sys |
| root |
+-------------+
5 rows in set (0.001 sec)
So I have probably created a user with no name, correct?所以我可能创建了一个没有名字的用户,对吗? Perhaps by using a wrong syntax in the past.也许是过去使用了错误的语法。 Question is how to drop
the user?问题是如何drop
用户? Something like the following doesn't seem to work:像下面这样的东西似乎不起作用:
MariaDB [(none)]> drop user ' ';
ERROR 1396 (HY000): Operation DROP USER failed for ' '@'%'
drop
is used to remove tables https://dev.mysql.com/doc/refman/8.0/en/drop-table.html , DROP TABLE User
drop
用于删除表https://dev.mysql.com/doc/refman/8.0/en/drop-table.html , DROP TABLE User
Try DELETE FROM User WHERE User.user = ' '
尝试DELETE FROM User WHERE User.user = ' '
After some trial and error I stumbled upon mysql.user does not exist .经过反复试验,我偶然发现了mysql.user 不存在。 During the execution of mysql_secure_installation
the terminal states在执行mysql_secure_installation
期间,终端状态
By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them.默认情况下,MariaDB 安装有一个匿名用户,允许任何人登录 MariaDB,而无需为其创建用户帐户。 This is intended only for testing, and to make the installation go a bit smoother.这仅用于测试,并使安装 go 更顺畅一些。 You should remove them before moving into a production environment.您应该在进入生产环境之前删除它们。
Remove anonymous users? [Y/n] Y
... Success!
So this ' ' user is equal to the anonymous user described here.所以这个''用户等于这里描述的匿名用户。 Running select distinct user from mysql.user;
运行select distinct user from mysql.user;
after the removal of anonymous users.删除匿名用户后。
Results in结果是
+-------------+
| User |
+-------------+
| app_user |
| test_u |
| mariadb.sys |
| root |
+-------------+
So probably this ' ' user was already there.所以可能这个“ ”用户已经在那里了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.