8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 27 存储对象 / 27.2 使用存储的例程 / 27.2.2 存储例程和 MySQL 权限
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

27.2.2 存储例程与 MySQL 权限27.2.2 Stored Routines and MySQL Privileges

MySQL 授权系统对存储例程的处理如下:The MySQL grant system takes stored routines into account as follows:

  • 创建存储例程需要 CREATE ROUTINE 权限。The CREATE ROUTINE privilege is needed to create stored routines.

  • 修改或删除存储例程需要 ALTER ROUTINE 权限。如果需要,这个权限会自动授予例程的创建者,当例程被删除时,这个权限也会从创建者那里撤销。The ALTER ROUTINE privilege is needed to alter or drop stored routines. This privilege is granted automatically to the creator of a routine if necessary, and dropped from the creator when the routine is dropped.

  • 执行存储例程需要EXECUTE权限。然而,如果需要,这个权限会自动授予例程的创建者(当例程被删除时,该权限也会从创建者处撤销)。此外,例程的默认SQL SECURITY特性是DEFINER,这使得有权访问与该例程相关的数据库的用户能够执行该例程。The EXECUTE privilege is required to execute stored routines. However, this privilege is granted automatically to the creator of a routine if necessary (and dropped from the creator when the routine is dropped). Also, the default SQL SECURITY characteristic for a routine is DEFINER, which enables users who have access to the database with which the routine is associated to execute the routine.

  • 如果 automatic_sp_privileges 系统变量为 0,则 EXECUTE 和 ALTER ROUTINE 权限不会自动授予给例程创建者,也不会自动从其移除。If the automatic_sp_privileges system variable is 0, the EXECUTE and ALTER ROUTINE privileges are not automatically granted to and dropped from the routine creator.

  • 例程的创建者是用于执行 CREATE 语句的账户。这可能与例程定义中作为 DEFINER 指定的账户不同。The creator of a routine is the account used to execute the CREATE statement for it. This might not be the same as the account named as the DEFINER in the routine definition.

  • 被指定为例程 DEFINER 的帐户可以查看所有例程属性,包括其定义。因此,该帐户可以完全访问例程输出,包括通过以下方式生成的输出:The account named as a routine DEFINER can see all routine properties, including its definition. The account thus has full access to the routine output as produced by:

  • 对于非例程 DEFINER 的帐户,访问例程属性取决于授予该帐户的权限:For an account other than the account named as the routine DEFINER, access to routine properties depends on the privileges granted to the account:

    • 拥有 SHOW_ROUTINE 权限或全局 SELECT 权限,账户可以查看所有例程属性,包括其定义。With the SHOW_ROUTINE privilege or the global SELECT privilege, the account can see all routine properties, including its definition.

    • 在包含该例程的范围内被授予 CREATE ROUTINE、ALTER ROUTINE 或 EXECUTE 权限时,账户可以查看除定义之外的所有例程属性。With the CREATE ROUTINE, ALTER ROUTINE or EXECUTE privilege granted at a scope that includes the routine, the account can see all routine properties except its definition.