【发布时间】:2021-10-28 15:32:33
【问题描述】:
我已从云中的 MySQL 8 数据库导出数据库,并将其导入本地计算机上相同版本的数据库,但导入失败并出现以下错误:
ERROR 1478 (HY000) at line 52372: InnoDB : A partitioned table is not allowed in a shared tablespace.
在加载它之前,我删除了删除数据库并重新制作了数据库。然后我运行database_name < sqldump.sql
我的本地 MySQL 配置如下所示:
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
max_allowed_packet = 1000M
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
我有什么办法:
- 将我本地 mysql 上的表空间设置为不共享,然后重新加载此文件?
- 创建一个非共享或通用表空间,并专门将此 sql 转储加载到该表空间?
我并不特别需要本地安装的 mysql 中的任何数据,因此如果需要,我可以完全摆脱那里的数据。
编辑:
- 在其中一张表上添加 create table 语句: 我有多个分区的表,所以我不确定是哪一个导致了问题,但这里是其中一个表的示例——我认为是最大的表:
indicators_v2_studentindicator | CREATE TABLE `indicators_v2_studentindicator` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime(6) NOT NULL,
`modified` datetime(6) NOT NULL,
`count` smallint(6) DEFAULT NULL,
`value` tinyint(1) NOT NULL,
`custom_completed_time` datetime(6) DEFAULT NULL,
`custom_completed_by_id` int(11) DEFAULT NULL,
`indicator_id` int(11) NOT NULL,
`student_id` int(11) NOT NULL,
`data_value` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`district_id` int(11) NOT NULL,
PRIMARY KEY (`id`,`district_id`),
UNIQUE KEY `unique_student_indicator` (`indicator_id`,`student_id`,`district_id`),
KEY `indicators_v2_studen_custom_completed_by__0b8259f0_fk_sl_users_` (`custom_completed_by_id`),
KEY `indicators_v2_studen_student_id_f5d95e9b_fk_sl_users_` (`student_id`),
KEY `indicators_v2_studen_indicator_id_k9h7g1b7_fk_indc_v2_` (`indicator_id`),
KEY `indicators__indicat_a34c4f_idx` (`indicator_id`,`student_id`,`district_id`,`value`),
KEY `indicators_v2_studentindicator_district_id_31e295d6` (`district_id`)
) ENGINE=InnoDB AUTO_INCREMENT=134160227 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
/*!50100 PARTITION BY LIST (`district_id`)
(PARTITION p_district_id_1 VALUES IN (1) TABLESPACE = `innodb_file_per_table` ENGINE = InnoDB,
PARTITION p_district_id_3 VALUES IN (3) TABLESPACE = `innodb_file_per_table` ENGINE = InnoDB,
... [many more partition statements, omitted for brevity]
PARTITION p_district_id_127 VALUES IN (127) TABLESPACE = `innodb_file_per_table` ENGINE = InnoDB,
PARTITION p_district_id_128 VALUES IN (128) TABLESPACE = `innodb_system` ENGINE = InnoDB,
奇怪的是,在某个时刻,我发现表空间实际上从 innodb_file_per_table 更改为 innodb_system -- 这可能是个问题吗?
【问题讨论】:
-
您能否将
SHOW CREATE TABLE <name>;的结果包含在您的分区表中?并且还包括SELECT VERSION();的结果。我在 MySQL 8.0.26 上进行了测试,我能够创建一个禁用innodb_file_per_table的分区表,但我没有收到此错误。 -
PARTITIONing很少有用;请提供SHOW CREATE TABLE。 -
@BillKarwin
8.0.19是我在本地机器上加载数据库的版本,8.0.16是从中转储数据库的版本。我正在添加这个和上面的创建表语句。 -
@RickJames 我们对表进行了分区,因为其中有 9000 万行,并且大多数操作发生在其中一个分区内。它大大加快了运营速度。
-
请告诉我们受益于
PARTITIONing的SELECT。
标签: mysql innodb partitioning