今天生产导入MySQL表遇到如下问题:
报错原因:
1.innodb存储引擎,多列索引的长度限制如下:
每个列的长度不能大于767 bytes;所有组成索引列的长度和不能大于3072 bytes
2 myisam存储引擎,多列索引长度限制如下:
每个列的长度不能大于1000 bytes,所有组成索引列的长度和不能大于1000 bytes
解决办法:
可以启用启用innodb_large_prefix参数,来使得单个索引字段的长度突破767
注意:
①启用innodb_large_prefix参数能够取消对于索引中每列长度的限制(但是无法取消对于索引总长度的限制)
②启用innodb_large_prefix必须同时指定innodb_file_format=barracuda,innodb_file_per_table=true,并且建表的时候指定表的row_format为dynamic或者compressed(mysql
5.6中row_format默认值为compact)
show variables like ‘innodb_large_prefix’;
show variables like ‘innodb_file_format’;
set global innodb_large_prefix=1;
set global innodb_file_format = BARRACUDA;