各种问题

2023-04-04  本文已影响0人  半理想主义

1、Specified key was too long; max key length is 767 bytes

 
mysql> set global innodb_file_format = BARRACUDA;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set global innodb_large_prefix = ON;
Query OK, 0 rows affected (0.00 sec)

2、Cannot delete or update a parent row: a foreign key constraint fails

删除表时报错

SET foreign_key_checks = 0; 
DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS;
DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE;
DROP TABLE IF EXISTS QRTZ_LOCKS;
DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
DROP TABLE IF EXISTS QRTZ_CALENDARS;
SET foreign_key_checks = 1;

3、[ERR] 1709 - Index column size too large. The maximum column size is 767 bytes.

image.png

导入ruoyi_v3.8.3的quartz.sql时出现这个提示
意思是说创建索引其中一个列的大小超过了MySQL允许的最大值,即767字节。

其实就是第一段

create table QRTZ_JOB_DETAILS (
    sched_name           varchar(120)    not null            comment '调度名称',
    job_name             varchar(200)    not null            comment '任务名称',
    job_group            varchar(200)    not null            comment '任务组名',
    description          varchar(250)    null                comment '相关介绍',
    job_class_name       varchar(250)    not null            comment '执行任务类名称',
    is_durable           varchar(1)      not null            comment '是否持久化',
    is_nonconcurrent     varchar(1)      not null            comment '是否并发',
    is_update_data       varchar(1)      not null            comment '是否更新数据',
    requests_recovery    varchar(1)      not null            comment '是否接受恢复执行',
    job_data             blob            null                comment '存放持久化job对象',
    primary key (sched_name, job_name, job_group)
) engine=innodb comment = '任务详细信息表';

MySQL的最大键长度为767个字节。发生在创建表时的主键(sched_name, job_name, job_group)上,其中列job_name和job_group每列varchar(200) ,可能需要将它们的长度缩短,例如改为varchar(100)或更少。

但我创建utf8字符集的数据库后导入就没有问题了


image.png

mysql的字符集utf8mb4和utf8区别在于

MySQL中的字符集UTF8和UTF8MB4都支持Unicode字符集,但它们之间存在一些差异。

UTF8最多可以使用3个字节存储一个字符,因此最大字符长度为255字节。而UTF8MB4可以使用最多4个字节来表示一个字符,因此最大字符长度为65535字节。这意味着UTF8MB4支持更广泛的Unicode字符集,并且可以存储表情符号等较大的字符。

在实践中,如果需要存储包含表情符号或其他较大字符的数据,应该使用UTF8MB4字符集。否则,在使用UTF8字符集时将会发生错误,例如"Error 1366: Incorrect string value"错误。

奇怪难道之前的ruoyi一直都是使用utf8字符集的数据库么

上一篇 下一篇

猜你喜欢

热点阅读