mysql报错:The maximum column size is 767 bytes; max key length is 767 bytes

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

Index column size too large. The maximum column size is 767 bytes

列、索引长度超出了限制大小:

innode引擎-索引的每列最长不能超过767bytes,组成索引的列长度和不能大于3072bytes
myisam引擎-索引的每列最长不能超过1000bytes;,组成索引的列长度和不能大于1000bytes

字符对应字节数:
utf8 3字节 utf8mb4 4字节

 

解决办法:

检查数据库是否被限制了索引的大小

show variables like 'innodb_large_prefix';

如果是OFF的话设置成ON:

SET GLOBAL INNODB_LARGE_PREFIX = ON;

检查当前的innodb_file_format引擎格式类型

show variables like 'innodb_file_format';

 如果不是BARRACUDA设置:

SET GLOBAL innodb_file_format = BARRACUDA

创建语句后面添加:

CREATE TABLE  TEST (...) ROW_FORMAT=DYNAMIC default charset utf8mb4;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章