MariaDB / MySQL 预先存在的数据库

MariaDB / MySQL pre-existing DB's

我想知道这三个预先存在的数据库有什么用?

information_schema
mysql
performance_schema

我很想知道我是否可以在简约环境中删除它们而不用担心任何后果。

您不能删除这些数据库。如果您更改表或以其他方式更改其中的内容,则可能会损坏您的服务器。

它们是 "fake" 数据库,用于元数据。他们不需要太多 space.

Mysql 会愚蠢地允许您删除 mysql 和 performance_schema 而不是信息模式。但是,您不应删除这些数据库,因为 Mysql 将停止正常运行。

例如,如果您删除 mysql 数据库,您仍然可以以 root 身份登录,并且 运行 'show databases; 但是如果您尝试 运行 show tables; 在数据库中,你会得到一个空集。

但是,您可以根据用户权限和授权来限制谁可以看到它们。

来自dev.mysql

performance_schema 数据库中的表是不永久存储数据的视图和临时表的集合。

The Performance Schema provides a way to inspect internal execution of the server at runtime. It is implemented using the PERFORMANCE_SCHEMA storage engine and the performance_schema database. The Performance Schema focuses primarily on performance data. This differs from INFORMATION_SCHEMA, which serves for inspection of metadata.

您可以运行此命令并获取有关线程的信息:

select name, type, instrumented from performance_schema.threads;

来自dev.mysql

INFORMATION_SCHEMA is a database within each MySQL instance, the place that stores information about all the other databases that the MySQL server maintains. The INFORMATION_SCHEMA database contains several read-only tables. They are actually views, not base tables, so there are no files associated with them, and you cannot set triggers on them. Also, there is no database directory with that name.

你可以运行这个命令来查看哪些数据库有MyISAM表:

select distinct(table_schema) FROM information_schema.tables where engine = 'MyISAM';

来自 dev.mysql.

The mysql system database includes several grant tables that contain information about user accounts and the privileges held by them.

您可以运行此命令查看用户和主机列表:

select user, host from mysql.user;