SHOW GRANTS

语法

SHOW GRANTS [FOR user|role]

描述

SHOW GRANTS 语句列出了授予特定用户或角色的权限。

用户

该语句列出了必须发出的 GRANT 语句或语句,以复制授予 MariaDB 用户帐户的权限。帐户的命名方式与 GRANT 语句相同;例如,'jeffrey'@'localhost'。如果您只指定帐户名称的用户名部分,则使用主机名部分 '%'。有关指定帐户名称的其他信息,请参见 GRANT

SHOW GRANTS FOR 'root'@'localhost';
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+

要列出授予您用于连接到服务器的帐户的特权,您可以使用以下任何语句:

SHOW GRANTS;
SHOW GRANTS FOR CURRENT_USER;
SHOW GRANTS FOR CURRENT_USER();

如果在 DEFINER 上下文中使用了 SHOW GRANTS FOR CURRENT_USER(或任何等效语法)(例如,在使用 SQL SECURITY DEFINER 定义的存储过程中),则显示的授权是定义者的授权,而不是调用者的授权。

请注意,自 MariaDB 10.3.4 起引入的 DELETE HISTORY 特权在运行 SHOW GRANTS 时显示为 DELETE VERSIONING ROWS,直到 MariaDB 10.3.15MDEV-17655)。

角色

SHOW GRANTS 还可用于查看授予 role 的特权。

示例

SHOW GRANTS FOR journalist;
+------------------------------------------+
| Grants for journalist                    |
+------------------------------------------+
| GRANT USAGE ON *.* TO 'journalist'       |
| GRANT DELETE ON `test`.* TO 'journalist' |
+------------------------------------------+

对于 PUBLIC

MariaDB starting with 10.11

GRANT ... TO PUBLICMariaDB 10.11 中引入,以将特权授予所有用户。SHOW GRANTS FOR PUBLIC 显示所有这些授权。

SHOW GRANTS FOR public;
+------------------------------------------------+
| Grants for PUBLIC                              |
+------------------------------------------------+
| GRANT ALL PRIVILEGES ON `dev_db`.* TO `PUBLIC` |
+------------------------------------------------+

另请参阅

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.