欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

mysql错误码1709_MySQL5.6出现ERROR 1709 (HY000): Index column size too large问题的解决方法...

发布时间:2025/3/11 78 豆豆
生活随笔 收集整理的这篇文章主要介绍了 mysql错误码1709_MySQL5.6出现ERROR 1709 (HY000): Index column size too large问题的解决方法... 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

一、问题

mysql 5.6 出现如下问题:

[ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.]

二、解决

根据文档所述

Prefix support and lengths of prefixes (where supported) are storage engine dependent. For example, a prefix can be up to 767 bytes long for InnoDB tables or 3072 bytes if the innodb_large_prefix option is enabled. For MyISAM tables, the prefix length limit is 1000 bytes.

innodb_large_prefix

根据以上可知,如果需要在长度大于255字符的字段上创建索引,需要修改以下3个参数

2. innodb_file_per_table=true

3. ROW_FORMAT=DYNAMIC or COMPRESSED

更改参数:

mysql> set global innodb_file_format = BARRACUDA;

mysql> set global innodb_large_prefix = ON;

在创建表时,需要 加 ROW_FORMAT=DYNAMIC 参数:

create table raw_log_meta_data(

id bigint NOT NULL AUTO_INCREMENT,

app_id varchar(64),

user_id varchar(128),

file_path varchar(512),

device_id varchar(128),

update_time DATETIME,

PRIMARY KEY (id),

UNIQUE KEY (user_id),

UNIQUE KEY (file_path)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

Query OK, 0 rows affected (0.29 sec)

作者:Corwien

总结

以上是生活随笔为你收集整理的mysql错误码1709_MySQL5.6出现ERROR 1709 (HY000): Index column size too large问题的解决方法...的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。