【问题标题】:Updating MySQL configuration to avid error: "A partitioned table is not allowed in a shared tablespace"将 MySQL 配置更新为 avid 错误:“共享表空间中不允许分区表”
【发布时间】: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"

我有什么办法:

  1. 将我本地 mysql 上的表空间设置为不共享,然后重新加载此文件?
  2. 创建一个非共享或通用表空间,并专门将此 sql 转储加载到该表空间?

我并不特别需要本地安装的 mysql 中的任何数据,因此如果需要,我可以完全摆脱那里的数据。

编辑:

  1. 在其中一张表上添加 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 万行,并且大多数操作发生在其中一个分区内。它大大加快了运营速度。
  • 请告诉我们受益于PARTITIONingSELECT

标签: mysql innodb partitioning


【解决方案1】:

https://dev.mysql.com/doc/refman/8.0/en/create-table.html#create-table-partitioning 说:

不支持将 InnoDB 表分区放在共享 InnoDB 表空间中。共享表空间包括 InnoDB 系统表空间和通用表空间。

所以改变这个:

PARTITION p_district_id_128 VALUES IN (128) TABLESPACE = `innodb_system` ENGINE = InnoDB,

到这里:

PARTITION p_district_id_128 VALUES IN (128) TABLESPACE = `innodb_file_per_table` ENGINE = InnoDB,

您不能使用除innodb_file_per_table 之外的任何值。据我所知,此选项的唯一目的是允许您覆盖配置选项 innodb_file_per_table,如果在您创建分区表时其全局设置为 OFF。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-29
    • 1970-01-01
    • 2013-01-16
    • 2020-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-22
    相关资源
    最近更新 更多