The mysql
schema is the system schema. mysql
模式是系统模式。It contains tables that store information required by the MySQL server as it runs. 它包含存储MySQL服务器运行时所需信息的表。A broad categorization is that the 一个广泛的分类是,mysql
schema contains data dictionary tables that store database object metadata, and system tables used for other operational purposes. mysql
模式包含存储数据库对象元数据的数据字典表,以及用于其他操作目的的系统表。The following discussion further subdivides the set of system tables into smaller categories.下面的讨论将系统表集进一步细分为更小的类别。
The remainder of this section enumerates the tables in each category, with cross references for additional information. Data dictionary tables and system tables use the 本节的其余部分列举了每个类别中的表,并提供了其他信息的交叉引用。除非另有说明,否则数据字典表和系统表使用InnoDB
storage engine unless otherwise indicated.InnoDB
存储引擎。
mysql
system tables and data dictionary tables reside in a single InnoDB
tablespace file named mysql.ibd
in the MySQL data directory. mysql
系统表和数据字典表位于mysql数据目录中一个名为mysql.ibd
的InnoDB
表空间文件中。Previously, these tables were created in individual tablespace files in the 以前,这些表是在mysql
database directory.mysql
数据库目录中的单个表空间文件中创建的。
Data-at-rest encryption can be enabled for the 可以为mysql
system schema tablespace. mysql
系统模式表空间启用静态数据加密。For more information, see Section 15.13, “InnoDB Data-at-Rest Encryption”.有关更多信息,请参阅第15.13节,“InnoDB静止数据加密”。
These tables comprise the data dictionary, which contains metadata about database objects. 这些表构成了数据字典,其中包含有关数据库对象的元数据。For additional information, see Chapter 14, MySQL Data Dictionary.有关更多信息,请参阅第14章,“MySQL数据字典”。
The data dictionary is new in MySQL 8.0. A data dictionary-enabled server entails some general operational differences compared to previous MySQL releases. 数据字典在MySQL 8.0中是新的。与以前的MySQL版本相比,启用数据字典的服务器在操作上有一些总体差异。For details, see Section 14.7, “Data Dictionary Usage Differences”. 有关详细信息,请参阅第14.7节,“数据字典用法差异”。Also, for upgrades to MySQL 8.0 from MySQL 5.7, the upgrade procedure differs somewhat from previous MySQL releases and requires that you verify the upgrade readiness of your installation by checking specific prerequisites. 此外,对于从MySQL 5.7升级到MySQL 8.0,升级过程与以前的MySQL版本有所不同,需要通过检查特定的先决条件来验证安装的升级准备情况。For more information, see Section 2.11, “Upgrading MySQL”, particularly Section 2.11.5, “Preparing Your Installation for Upgrade”.有关更多信息,请参阅第2.11节,“升级MySQL”,特别是第2.11.5节,“准备升级安装”。
catalogs
: Catalog information.:目录信息。
character_sets
: Information about available character sets.:有关可用字符集的信息。
check_constraints
: Information about :有关在表上定义的CHECK
constraints defined on tables. CHECK
约束的信息。See Section 13.1.20.6, “CHECK Constraints”.请参阅第13.1.20.6节,“检查约束条件”。
collations
: Information about collations for each character set.:有关每个字符集的排序规则的信息。
column_statistics
: Histogram statistics for column values. :列值的直方图统计信息。See Section 8.9.6, “Optimizer Statistics”.请参阅第8.9.6节,“优化器统计”。
column_type_elements
: Information about types used by columns.:有关列使用的类型的信息。
columns
: Information about columns in tables.:有关表中列的信息。
dd_properties
: A table that identifies data dictionary properties, such as its version. The server uses this to determine whether the data dictionary must be upgraded to a newer version.:一个表,用于标识数据字典属性,例如其版本。服务器使用它来确定是否必须将数据字典升级到更新的版本。
events
: Information about Event Scheduler events. :有关事件计划程序事件的信息。See Section 25.4, “Using the Event Scheduler”. 请参阅第25.4节,“使用事件调度器”。If the server is started with the 如果服务器是使用--skip-grant-tables
option, the event scheduler is disabled and events registered in the table do not run. --skip-grant-tables
选项启动的,则会禁用事件调度程序,并且表中注册的事件不会运行。See Section 25.4.2, “Event Scheduler Configuration”.请参阅第25.4.2节,“事件调度器配置”。
foreign_keys
, foreign_key_column_usage
: Information about foreign keys.:有关外键的信息。
index_column_usage
: Information about columns used by indexes.:有关索引使用的列的信息。
index_partitions
: Information about partitions used by indexes.:有关索引使用的分区的信息。
index_stats
: Used to store dynamic index statistics generated when :用于存储在执行ANALYZE TABLE
is executed.ANALYZE TABLE
时生成的动态索引统计信息。
indexes
: Information about table indexes.:有关表索引的信息。
innodb_ddl_log
: Stores DDL logs for crash-safe DDL operations.:存储用于崩溃安全DDL操作的DDL日志。
parameter_type_elements
: Information about stored procedure and function parameters, and about return values for stored functions.:有关存储过程和函数参数的信息,以及有关存储函数的返回值的信息。
parameters
: Information about stored procedures and functions. :有关存储过程和函数的信息。See Section 25.2, “Using Stored Routines”.请参阅第25.2节,“使用存储例程”。
resource_groups
: Information about resource groups. :有关资源组的信息。See Section 5.1.16, “Resource Groups”.请参阅第5.1.16节,“资源组”。
routines
: Information about stored procedures and functions. See Section 25.2, “Using Stored Routines”.:有关存储过程和函数的信息。参见第25.2节,“使用存储例程”。
schemata
: Information about schemata. In MySQL, a schema is a database, so this table provides information about databases.:关于schemata的信息。在MySQL中,模式是数据库,因此此表提供了有关数据库的信息。
st_spatial_reference_systems
: Information about available spatial reference systems for spatial data.:关于空间数据的可用空间参考系统的信息。
table_partition_values
: Information about values used by table partitions.:有关表分区使用的值的信息。
table_partitions
: Information about partitions used by tables.:有关表使用的分区的信息。
table_stats
: Information about dynamic table statistics generated when :有关在执行ANALYZE TABLE
is executed.ANALYZE TABLE
时生成的动态表统计信息。
tables
: Information about tables in databases.:有关数据库中表的信息。
tablespace_files
: Information about files used by tablespaces.:有关表空间使用的文件的信息。
tablespaces
: Information about active tablespaces.:有关活动表空间的信息。
triggers
: Information about triggers.:有关触发器的信息。
view_routine_usage
: Information about dependencies between views and stored functions used by them.:有关视图与其使用的存储函数之间的依赖关系的信息。
view_table_usage
: Used to track dependencies between views and their underlying tables.:用于跟踪视图及其基础表之间的依赖关系。
Data dictionary tables are invisible. 数据字典表是不可见的。They cannot be read with 它们不能用SELECT
, do not appear in the output of SHOW TABLES
, are not listed in the INFORMATION_SCHEMA.TABLES
table, and so forth. SELECT
读取,不出现在SHOW TABLES
的输出中,不列在INFORMATION_SCHEMATABLES
表中,等等。However, in most cases there are corresponding 但是,在大多数情况下,可以查询相应的INFORMATION_SCHEMA
tables that can be queried. INFORMATION_SCHEMA
表。Conceptually, the 从概念上讲,INFORMATION_SCHEMA
provides a view through which MySQL exposes data dictionary metadata. INFORMATION_SCHEMA
提供了一个视图,MySQL通过该视图公开数据字典元数据。For example, you cannot select from the 例如,您不能直接从mysql.schemata
table directly:mysql.schemata
表中选择:
mysql> SELECT * FROM mysql.schemata;
ERROR 3554 (HY000): Access to data dictionary table 'mysql.schemata' is rejected.
Instead, select that information from the corresponding 相反,从相应的INFORMATION_SCHEMA
table:INFORMATION_SCHEMA
表中选择该信息:
mysql> SELECT * FROM INFORMATION_SCHEMA.SCHEMATA\G
*************************** 1. row ***************************
CATALOG_NAME: def
SCHEMA_NAME: mysql
DEFAULT_CHARACTER_SET_NAME: utf8mb4
DEFAULT_COLLATION_NAME: utf8mb4_0900_ai_ci
SQL_PATH: NULL
DEFAULT_ENCRYPTION: NO
*************************** 2. row ***************************
CATALOG_NAME: def
SCHEMA_NAME: information_schema
DEFAULT_CHARACTER_SET_NAME: utf8
DEFAULT_COLLATION_NAME: utf8_general_ci
SQL_PATH: NULL
DEFAULT_ENCRYPTION: NO
...
There is no 没有与INFORMATION_SCHEMA
table that corresponds exactly to mysql.indexes
, but INFORMATION_SCHEMA.STATISTICS
contains much of the same information.mysql.indexes
完全对应的INFORMATION_SCHEMA
表,但INFORMATION_SCHEMA.STATISTICS
包含许多相同的信息。
As of yet, there are no 到目前为止,还没有INFORMATION_SCHEMA
tables that correspond exactly to mysql.foreign_keys
, mysql.foreign_key_column_usage
. INFORMATION_SCHEMA
表与mysql.foreign_keys
、mysql.foreign_6key_column_usage
完全对应。The standard SQL way to obtain foreign key information is by using the 获取外键信息的标准SQL方法是使用INFORMATION_SCHEMA
REFERENTIAL_CONSTRAINTS
and KEY_COLUMN_USAGE
tables; these tables are now implemented as views on the foreign_keys
, foreign_key_column_usage
, and other data dictionary tables.INFORMATION_SCHEMA
REFERENTIAL_COCONSTRAINTS
和KEY_COLUMN_USAGE
表;这些表现在被实现为foreign_keys
、foreign_key_column_usage
和其他数据字典表的视图。
Some system tables from before MySQL 8.0 have been replaced by data dictionary tables and are no longer present in the MySQL 8.0之前的一些系统表已被数据字典表取代,并且不再出现在mysql
system schema:mysql
系统模式中:
The events
data dictionary table supersedes the event
table from before MySQL 8.0.events
数据字典表将取代MySQL 8.0之前的event
表。
The parameters
and routines
data dictionary tables together supersede the proc
table from before MySQL 8.0.parameters
和routines
数据字典表一起取代了MySQL 8.0之前的proc
表。
These system tables contain grant information about user accounts and the privileges held by them. 这些系统表包含有关用户帐户及其权限的授予信息。For additional information about the structure, contents, and purpose of the these tables, see Section 6.2.3, “Grant Tables”.有关这些表格的结构、内容和用途的更多信息,请参阅第6.2.3节,“Grant表格”。
As of MySQL 8.0, the grant tables are 从MySQL 8.0开始,grant表是InnoDB
(transactional) tables. InnoDB
(transactional)表。Previously, these were 以前,这些是MyISAM
(nontransactional) tables. MyISAM
(非事务性)表。The change of grant-table storage engine underlies an accompanying change in MySQL 8.0 to the behavior of account-management statements such as grant表存储引擎的更改是MySQL 8.0中对帐户管理语句(如CREATE USER
and GRANT
. CREATE USER
和GRANT
)行为的相应更改的基础。Previously, an account-management statement that named multiple users could succeed for some users and fail for others. 以前,命名多个用户的帐户管理语句对某些用户可能成功,对其他用户可能失败。The statements are now transactional and either succeed for all named users or roll back and have no effect if any error occurs.这些语句现在是事务性的,要么对所有命名用户成功,要么回滚,如果出现任何错误,则不起作用。
If MySQL is upgraded from an older version but the grant tables have not been upgraded from 如果MySQL是从旧版本升级的,但授权表尚未从MyISAM
to InnoDB
, the server considers them read only and account-management statements produce an error. MyISAM
升级到InnoDB
,则服务器会认为它们是只读的,并且帐户管理语句会产生错误。For upgrade instructions, see Section 2.11, “Upgrading MySQL”.有关升级说明,请参阅第2.11节,“升级MySQL”。
user
: User accounts, global privileges, and other nonprivilege columns.:用户帐户、全局特权和其他非特权列。
global_grants
: Assignments of dynamic global privileges to users; see Static Versus Dynamic Privileges.:为用户分配动态全局权限;请参阅静态权限与动态权限。
db
: Database-level privileges.:数据库级别的权限。
tables_priv
: Table-level privileges.:表级特权。
columns_priv
: Column-level privileges.:列级特权。
procs_priv
: Stored procedure and function privileges.:存储过程和函数权限。
proxies_priv
: Proxy-user privileges.:代理用户权限。
default_roles
: This table lists default roles to be activated after a user connects and authenticates, or executes :此表列出了用户连接并验证或执行SET ROLE DEFAULT
.SET ROLE DEFAULT
后要激活的默认角色。
role_edges
: This table lists edges for role subgraphs.:此表列出了角色子图的边。
A given 给定的user
table row might refer to a user account or a role. user
表行可能引用用户帐户或角色。The server can distinquish whether a row represents a user account, a role, or both by consulting the 服务器可以通过查阅role_edges
table for information about relations between authentication IDs.role_edges
表以获取有关身份验证ID之间关系的信息来区分一行是代表用户帐户还是代表角色,或者同时代表两者。
password_history
: Information about password changes.:有关密码更改的信息。
These system tables contain information about components, loadable functions, and server-side plugins:这些系统表包含有关组件、可加载函数和服务器端插件的信息:
component
: The registry for server components installed using :使用INSTALL COMPONENT
. Any components listed in this table are installed by a loader service during the server startup sequence. INSTALL COMPONENT
安装的服务器组件的注册表。此表中列出的任何组件都是由加载程序服务在服务器启动过程中安装的。See Section 5.5.1, “Installing and Uninstalling Components”.请参阅第5.5.1节,“安装和卸载组件”。
func
: The registry for loadable functions installed using :使用CREATE FUNCTION
. CREATE FUNCTION
安装的可加载函数的注册表。During the normal startup sequence, the server loads functions registered in this table. 在正常启动序列中,服务器加载此表中注册的函数。If the server is started with the 如果服务器是使用--skip-grant-tables
option, functions registered in the table are not loaded and are unavailable. --skip-grant-tables
选项启动的,则表中注册的函数将不会加载并且不可用。See Section 5.7.1, “Installing and Uninstalling Loadable Functions”.请参阅第5.7.1节,“安装和卸载可加载功能”。
Like the 与mysql.func
system table, the Performance Schema user_defined_functions
table lists loadable functions installed using CREATE FUNCTION
. mysql.func
系统表一样,性能模式user_defined_functions
表列出了使用CREATE FUNCTION
安装的可加载函数。Unlike the 与mysql.func
table, the user_defined_functions
table also lists functions installed automatically by server components or plugins. mysql.func
表不同,user_defined_functions
表还列出了服务器组件或插件自动安装的函数。This difference makes 这种差异使得user_defined_functions
preferable to mysql.func
for checking which functions are installed. user_defined_functions
在检查安装了哪些函数时比mysql.func
更可取。See Section 27.12.21.8, “The user_defined_functions Table”.请参阅第27.12.21.8节,“用户定义函数表”。
plugin
: The registry for server-side plugins installed using :使用INSTALL PLUGIN
. INSTALL_PLUGIN
安装的服务器端插件的注册表。During the normal startup sequence, the server loads plugins registered in this table. 在正常的启动序列中,服务器加载在此表中注册的插件。If the server is started with the 如果服务器是用--skip-grant-tables
option, plugins registered in the table are not loaded and are unavailable. --skip-grant-tables
选项启动的,那么表中注册的插件将不会加载并且不可用。See Section 5.6.1, “Installing and Uninstalling Plugins”.请参阅第5.6.节,“安装和卸载插件”。
The server uses these system tables for logging:服务器使用以下系统表进行日志记录:
general_log
: The general query log table.:常规查询日志表。
slow_log
: The slow query log table.:慢速查询日志表。
Log tables use the 日志表使用CSV
storage engine.CSV
存储引擎。
For more information, see Section 5.4, “MySQL Server Logs”.有关更多信息,请参阅第5.4节,“MySQL服务器日志”。
These system tables contain server-side help information:这些系统表包含服务器端帮助信息:
help_category
: Information about help categories.:有关帮助类别的信息。
help_keyword
: Keywords associated with help topics.:与帮助主题关联的关键字。
help_relation
: Mappings between help keywords and topics.:帮助关键字和主题之间的映射。
help_topic
: Help topic contents.:帮助主题内容。
For more information, see Section 5.1.17, “Server-Side Help Support”.有关更多信息,请参阅第5.1.17节,“服务器端帮助支持”。
These system tables contain time zone information:这些系统表包含时区信息:
time_zone
: Time zone IDs and whether they use leap seconds.:时区ID以及它们是否使用闰秒。
time_zone_leap_second
: When leap seconds occur.:当闰秒出现时。
time_zone_name
: Mappings between time zone IDs and names.:时区ID和名称之间的映射。
time_zone_transition
, time_zone_transition_type
: Time zone descriptions.:时区描述。
For more information, see Section 5.1.15, “MySQL Server Time Zone Support”.有关更多信息,请参阅第5.1.15节,“MySQL Server时区支持”。
The server uses these system tables to support replication:服务器使用这些系统表来支持复制:
gtid_executed
: Table for storing GTID values. See mysql.gtid_executed Table.:用于存储GTID值的表。请参见mysql.gtid_executed
表。
ndb_binlog_index
: Binary log information for NDB Cluster replication. :NDB群集复制的二进制日志信息。This table is created only if the server is built with 只有在使用NDBCLUSTER
support. NDBCLUSTER
支持构建服务器时,才会创建此表。See Section 23.6.4, “NDB Cluster Replication Schema and Tables”.请参阅第23.6.4节,“NDB群集复制模式和表”。
slave_master_info
, slave_relay_log_info
, slave_worker_info
: Used to store replication information on replica servers. :用于在副本服务器上存储复制信息。See Section 17.2.4, “Relay Log and Replication Metadata Repositories”.请参阅第17.2.4节,“中继日志和复制元数据存储库”。
All of the tables just listed use the 刚才列出的所有表都使用InnoDB
storage engine.InnoDB
存储引擎。
These system tables are for use by the optimizer:这些系统表供优化器使用:
innodb_index_stats
, innodb_table_stats
: Used for 用于InnoDB
persistent optimizer statistics. See Section 15.8.10.1, “Configuring Persistent Optimizer Statistics Parameters”.InnoDB
持久优化器统计信息。请参阅第15.8.10.1节,“配置持久优化器统计参数”。
server_cost
, engine_cost
: The optimizer cost model uses tables that contain cost estimate information about operations that occur during query execution. :优化器成本模型使用的表包含有关查询执行过程中发生的操作的成本估计信息。server_cost
contains optimizer cost estimates for general server operations. 包含一般服务器操作的优化器成本估计。engine_cost
contains estimates for operations specific to particular storage engines. engine_cost
包含特定于特定存储引擎的操作的估计。See Section 8.9.5, “The Optimizer Cost Model”.请参阅第8.9.5节,“优化器成本模型”。
Other system tables do not fit the preceding categories:其他系统表不符合上述类别:
audit_log_filter
, audit_log_user
: If MySQL Enterprise Audit is installed, these tables provide persistent storage of audit log filter definitions and user accounts. See Audit Log Tables.:如果安装了MySQL Enterprise Audit,这些表将提供审核日志筛选器定义和用户帐户的持久存储。请参阅审核日志表。
firewall_group_allowlist
, firewall_groups
, firewall_memebership
, firewall_users
, firewall_whitelist
: If MySQL Enterprise Firewall is installed, these tables provide persistent storage for information used by the firewall. See Section 6.4.7, “MySQL Enterprise Firewall”.:如果安装了MySQL企业防火墙,这些表将为防火墙使用的信息提供持久存储。请参阅第6.4.7节,“MySQL企业防火墙”。
servers
: Used by the :由FEDERATED
storage engine. See Section 16.8.2.2, “Creating a FEDERATED Table Using CREATE SERVER”.FEDERATED
存储引擎使用。参见第16.8.2.2节,“使用CREATE SERVER创建一个FEDERATED表”。
innodb_dynamic_metadata
: Used by the :由InnoDB
storage engine to store fast-changing table metadata such as auto-increment counter values and index tree corruption flags. InnoDB
存储引擎用于存储快速变化的表元数据,如自动递增计数器值和索引树损坏标志。Replaces the data dictionary buffer table that resided in the 替换InnoDB
system tablespace.InnoDB
系统表空间中的数据字典缓冲区表。