mysql
数据库是系统数据库
。它包含存储 MySQL 服务器运行时所需信息的表。
数据库中的表mysql
分为以下几类:
本节的其余部分列举了每个类别中的表格,并带有交叉引用以获取更多信息。MyISAM
除非另有说明,否则
系统表使用存储引擎。
不要将数据库中的 MySQL 系统表
mysql
从转换MyISAM
为InnoDB
表。这是不受支持的操作。如果这样做,MySQL 不会重新启动,直到您从备份中恢复旧系统表或通过重新初始化数据目录重新生成它们(请参阅
第 2.10.1 节,“初始化数据目录”)。
这些系统表包含有关用户帐户及其拥有的权限的授权信息:
For more information about the structure, contents, and purpose of the grant tables, see Section 6.2.3, “Grant Tables”.
These system tables contain information about stored programs, loadable functions, and server-side plugins:
event
: The registry for Event Scheduler events installed usingCREATE EVENT
. 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. See Section 23.4.2, “Event Scheduler Configuration”.func
: The registry for loadable functions installed usingCREATE 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. See Section 5.6.1, “Installing and Uninstalling Loadable Functions”.plugin
: The registry for server-side plugins installed usingINSTALL 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. See Section 5.5.1, “Installing and Uninstalling Plugins”.The
plugin
table uses theInnoDB
storage engine as of MySQL 5.7.6,MyISAM
before that.proc
: Information about stored procedures and functions. See Section 23.2, “Using Stored Routines”.
The server uses these system tables for logging:
Log tables use the CSV
storage engine.
For more information, see Section 5.4, “MySQL Server Logs”.
These system tables contain server-side help information:
These tables use the InnoDB
storage engine as
of MySQL 5.7.5, MyISAM
before that.
For more information, see Section 5.1.14, “Server-Side Help Support”.
These system tables contain time zone information:
These tables use the InnoDB
storage engine as
of MySQL 5.7.5, MyISAM
before that.
For more information, see Section 5.1.13, “MySQL Server Time Zone Support”.
The server uses these system tables to support replication:
gtid_executed
: Table for storing GTID values. See mysql.gtid_executed Table.The
gtid_executed
table uses theInnoDB
storage engine.ndb_binlog_index
: Binary log information for NDB Cluster replication. See Section 21.7.4, “NDB Cluster Replication Schema and Tables”.Prior to NDB 7.5.2, this table employed the
MyISAM
storage engine. In NDB 7.5.2 and later, it usesInnoDB
. If you are planning an upgrade from a NDB Cluster previous release to NDB 7.5.2 or later, see Section 21.3.7, “Upgrading and Downgrading NDB Cluster”, for important information relating to this change.slave_master_info
,slave_relay_log_info
,slave_worker_info
: Used to store replication information on replica servers. See Section 16.2.4, “Relay Log and Replication Metadata Repositories”.All three of these tables use the
InnoDB
storage engine.
These system tables are for use by the optimizer:
innodb_index_stats
,innodb_table_stats
: Used forInnoDB
persistent optimizer statistics. See Section 14.8.11.1, “Configuring Persistent Optimizer Statistics Parameters”.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. See Section 8.9.5, “The Optimizer Cost Model”.
These tables use the InnoDB
storage engine.
Other system tables do not fall into 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.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.6, “MySQL Enterprise Firewall”.servers
: Used by theFEDERATED
storage engine. See Section 15.8.2.2, “Creating a FEDERATED Table Using CREATE SERVER”.该
servers
表在此之前使用InnoDB
MySQL 5.7.6 的存储引擎MyISAM
。