英文:
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 ...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论