xiaohanshe 发表于 2021-10-19 11:04

有没有mysql大佬,帮我看看:[Err] 1071 - Specified key was too long; max key l...

MySQL版本6.0
错误: 1071 - Specified key was too long; max key length is 767 bytes
sql:
DROP TABLE IF EXISTS `qrtz_triggers`;
CREATE TABLE `qrtz_triggers`(
`SCHED_NAME` varchar(120) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`JOB_NAME` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`JOB_GROUP` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`DESCRIPTION` varchar(250) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`NEXT_FIRE_TIME` bigint(13) NULL DEFAULT NULL,
`PREV_FIRE_TIME` bigint(13) NULL DEFAULT NULL,
`PRIORITY` int(11) NULL DEFAULT NULL,
`TRIGGER_STATE` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`TRIGGER_TYPE` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`START_TIME` bigint(13) NOT NULL,
`END_TIME` bigint(13) NULL DEFAULT NULL,
`CALENDAR_NAME` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`MISFIRE_INSTR` smallint(2) NULL DEFAULT NULL,
`JOB_DATA` blob NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
INDEX `SCHED_NAME`(`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) USING BTREE,
CONSTRAINT `qrtz_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) REFERENCES `qrtz_job_details` (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'InnoDB free: 504832 kB; (`SCHED_NAME` `JOB_NAME` `JOB_GROUP`' ROW_FORMAT = Dynamic;

RyanLi 发表于 2021-10-19 11:44

百度---错误: 1071 - Specified key was too long; max key length is 767 bytes

choujie1689 发表于 2021-10-19 11:49

1.在mysql 5.5.3之前,mysql的InnoDB引擎,要求设置的主键长度不得超过767bytes。

解决方法把联合主键的长度变小点。当然这只适合练习用。

常规方法应该是升级mysql版本。

因为mysql5.7版本的字节最大长度为3072。

sdi 发表于 2021-10-19 11:51

mysql和C语言差别还挺大的

l943644670 发表于 2021-10-19 11:51

给my.cnf里加个 innodb_large_prefix = on   重启服务再试试

zyy22664488 发表于 2021-10-19 12:00

mysql语言感觉和pyhon差不多

njbb888 发表于 2021-10-19 13:45

sdi 发表于 2021-10-19 11:51
mysql和C语言差别还挺大的

有什么关系???

brightwill 发表于 2021-10-19 13:53

改变varchar的字符数,varchar(64),或者启用innodb_large_prefix,那么限制值会增加到3072

xiaohanshe 发表于 2021-10-19 14:59

brightwill 发表于 2021-10-19 13:53
改变varchar的字符数,varchar(64),或者启用innodb_large_prefix,那么限制值会增加到3072

我的是6.0版本,根本没有这个:innodb_large_prefix=ON

xiaohanshe 发表于 2021-10-19 15:01

15820394839 发表于 2021-10-19 11:49
1.在mysql 5.5.3之前,mysql的InnoDB引擎,要求设置的主键长度不得超过767bytes。

解决方法把联合主键的 ...

我的版本是6.0啊
页: [1] 2
查看完整版本: 有没有mysql大佬,帮我看看:[Err] 1071 - Specified key was too long; max key l...