将默认 mysql 数据库表的 MariaDB 存储引擎更改为 InnoDB:db、host 和 user

Change MariaDB storage engine to InnoDB for default mysql database tables: db, host and user

可以更改特定 table 的存储引擎类型:

ALTER TABLE table_name ENGINE = InnoDB;

这适用于除 MariaDB/MySQL 安装附带的数据库、主机和用户 table 之外的所有 table。它抛出一个(通用)错误:

MariaDB [mysql]> ALTER TABLE db ENGINE = InnoDB;
ERROR 1025 (HY000): Error on rename of './mysql/#sql-149_24b' to './mysql/db' (errno: 168 "Unknown (generic) error from engine")
MariaDB [mysql]> ALTER TABLE host ENGINE = InnoDB;
ERROR 1025 (HY000): Error on rename of './mysql/#sql-149_24b' to './mysql/host' (errno: 168 "Unknown (generic) error from engine")
MariaDB [mysql]> ALTER TABLE user ENGINE = InnoDB;
ERROR 1025 (HY000): Error on rename of './mysql/#sql-149_24b' to './mysql/user' (errno: 168 "Unknown (generic) error from engine")

我明白为什么更改 运行 数据库上的 table 引擎会对这些特定的 table 造成问题(因为它们包含数据库和用户信息)。但是如何改变这一点呢?

您无法更改引擎

In MariaDB 10.3 and before, this table uses the MyISAM storage engine.

为什么不更新

In MariaDB 10.4 and later, the mysql.global_priv table has replaced the mysql.user table, and mysql.user should be considered obsolete.

manual

不要,重复,不要,尝试更改预定义的 mysqlinformation_schemaperformance_schema 数据库中 table 的任何定义在 MySQL 个服务器中。这些 table 由服务器软件本身管理,如果您更改它们,可能会损坏您的服务器。

也不要尝试 table 中的 UPDATEINSERT 行。使用数据定义语言 SQL 语句。

而且,ALTER TABLE table_name ENGINE = InnoDB; 不会更改 默认 存储引擎。相反,它更改了名为 table_name 的 table 的存储引擎。