文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 29 MySQL Performance Schema / 29.11 Performance Schema General Table Characteristics
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

29.11 Performance Schema 一般表特性29.11 Performance Schema General Table Characteristics

performance_schema 数据库的名称为小写,其内表的名称也是小写。查询时应使用小写名称。The name of the performance_schema database is lowercase, as are the names of tables within it. Queries should specify the names in lowercase.

performance_schema 数据库中的许多表是只读的,无法修改:Many tables in the performance_schema database are read only and cannot be modified:

mysql> TRUNCATE TABLE performance_schema.setup_instruments;
ERROR 1683 (HY000): Invalid performance_schema usage.

一些设置表有可以修改的列,以影响 Performance Schema 的操作;有些还允许插入或删除行。允许使用截断来清除收集的事件,因此可以在包含这些类型信息的表上使用 TRUNCATE TABLE,例如以 events_waits_ 为前缀命名的表。Some of the setup tables have columns that can be modified to affect Performance Schema operation; some also permit rows to be inserted or deleted. Truncation is permitted to clear collected events, so TRUNCATE TABLE can be used on tables containing those kinds of information, such as tables named with a prefix of events_waits_.

可以使用 TRUNCATE TABLE 截断汇总表。通常,其效果是将汇总列重置为 0 或 NULL,而不是删除行。这使您能够清除收集的值并重新开始汇总。例如,在您进行运行时配置更改后,这可能会很有用。各个汇总表部分会注明这种截断行为的例外情况。Summary tables can be truncated with TRUNCATE TABLE. Generally, the effect is to reset the summary columns to 0 or NULL, not to remove rows. This enables you to clear collected values and restart aggregation. That might be useful, for example, after you have made a runtime configuration change. Exceptions to this truncation behavior are noted in individual summary table sections.

权限与其他数据库和表相同:Privileges are as for other databases and tables:

  • 要从 performance_schema 表中检索数据,您必须拥有 SELECT 权限。To retrieve from performance_schema tables, you must have the SELECT privilege.

  • 要更改可以修改的那些列,您必须拥有UPDATE 权限。To change those columns that can be modified, you must have the UPDATE privilege.

  • 要截断可以截断的表,您必须拥有DROP 权限。To truncate tables that can be truncated, you must have the DROP privilege.

由于只有有限的一组权限适用于 Performance Schema 表,尝试使用 GRANT ALL 作为在数据库或表级别授予权限的简写会导致错误:Because only a limited set of privileges apply to Performance Schema tables, attempts to use GRANT ALL as shorthand for granting privileges at the database or table level fail with an error:

mysql> GRANT ALL ON performance_schema.*
       TO 'u1'@'localhost';
ERROR 1044 (42000): Access denied for user 'root'@'localhost'
to database 'performance_schema'
mysql> GRANT ALL ON performance_schema.setup_instruments
       TO 'u2'@'localhost';
ERROR 1044 (42000): Access denied for user 'root'@'localhost'
to database 'performance_schema'

相反,应授予确切所需的权限:Instead, grant exactly the desired privileges:

mysql> GRANT SELECT ON performance_schema.*
       TO 'u1'@'localhost';
Query OK, 0 rows affected (0.03 sec)

mysql> GRANT SELECT, UPDATE ON performance_schema.setup_instruments
       TO 'u2'@'localhost';
Query OK, 0 rows affected (0.02 sec)