如何撤销具有双引号的用户授权

huangapple go评论50阅读模式
英文:

How to revoke grants for a user with double quotes in it

问题

I have mistakenly created and granted permissions to a user with double quotes in it in my mariadb database.

MariaDB [mysql]> select * from information_schema.user_privileges;

+--------------------------------------+---------------+-------------------------+--------------+
| GRANTEE                              | TABLE_CATALOG | PRIVILEGE_TYPE          | IS_GRANTABLE |
+--------------------------------------+---------------+-------------------------+--------------+
| '"bob@grr.la"'@'%'                   | def           | SELECT                  | NO           |
| '"bob@grr.la"'@'%'                   | def           | INSERT                  | NO           |
| '"bob@grr.la"'@'%'                   | def           | UPDATE                  | NO           |
| '"bob@grr.la"'@'%'                   | def           | DELETE                  | NO           |
...
+--------------------------------------+---------------+-------------------------+--------------+

I have tried many different escape combinations but I don't seem to be able to target that user when I try to revoke privileges for it.

I have tried:

revoke all, grant option from '"bob@grr.la"'@'%';
revoke all, grant option from "bob@grr.la"@'%';
revoke all, grant option from \"bob@grr.la\"@'%';
revoke all, grant option from "%bob%"@'%';
revoke all, grant option from '%bob%'@'%';

None of those work. What gives?

英文:

I have mistakenly created and granted permissions to a user with double quotes in it in my mariadb database.

MariaDB [mysql]> select * from information_schema.user_privileges;

+--------------------------------------+---------------+-------------------------+--------------+
| GRANTEE                              | TABLE_CATALOG | PRIVILEGE_TYPE          | IS_GRANTABLE |
+--------------------------------------+---------------+-------------------------+--------------+
  ...																							 
| '"bob@grr.la"'@'%'		           | def           | SELECT                  | NO           |
| '"bob@grr.la"'@'%'		           | def           | INSERT                  | NO           |
| '"bob@grr.la"'@'%'		           | def           | UPDATE                  | NO           |
| '"bob@grr.la"'@'%'		           | def           | DELETE                  | NO           |
  ...
+--------------------------------------+---------------+-------------------------+--------------+

I have tried many different escape combinations but I don't seem to be able to target that user when I try to revoke privileges for it.

I have tried:

revoke all, grant option from '"bob@grr.la"'@'%';
revoke all, grant option from "bob@grr.la"@'%';
revoke all, grant option from \"bob@grr.la\"@'%';
revoke all, grant option from "%bob%"@'%';
revoke all, grant option from '%bob%'@'%';

None of those work. What gives?

答案1

得分: 0

需要转义双引号,例如:

MariaDB [(none)]> create user ''"bob@grr.la"''@'%';
查询已成功,影响行数为0(0.01秒)

MariaDB [(none)]> grant all on test.* to ''"bob@grr.la"''@'%';
查询已成功,影响行数为0(0.01秒)

MariaDB [(none)]> revoke all privileges, grant option from ''"bob@grr.la"''@'%';
查询已成功,影响行数为0(0.01秒)

英文:

You need to escape the double quote, e.g.:

MariaDB [(none)]> create user '\"bob@grr.la\"'@'%';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> grant all on test.* to '\"bob@grr.la\"'@'%';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> revoke all privileges, grant option from '\"bob@grr.la\"'@'%';
Query OK, 0 rows affected (0.01 sec)

答案2

得分: 0

"REVOKE"命令必须与"GRANT"具有完全相同的参数。例如,GRANT SELECT ...不会被REVOKE ALL PRIVILEGES ...撤销。

英文:

The REVOKE command must have exactly the same arguments that the GRANT had. For example, GRANT SELECT ... is not undone by REVOKE ALL PRIVILEGES ...

huangapple
  • 本文由 发表于 2020年1月7日 01:07:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616200.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定