今天测试同事在导入mysql脚本时遇到错误:Specified key was too long; max key length is 767 bytes
经过百度,错误原因为:
数据库表采用utf8编码,其中varchar(255)的column进行了唯一键索引,而mysql默认情况下单个列的索引不能超过767位,于是utf8字符编码下,255*3 byte 超过限制(测试5.7以上版本是没问题的,5.6及以下不行)
进一步百度,确认如下解决方案:
1 、使用innodb引擎;
2 、启用innodb_large_prefix选项,将约束项扩展至3072bytes
3、设置 innodb_file_format为 Barracuda (5.6版本默认为 Antelope,相关介绍,请参阅:
https://www.cnblogs.com/wilburxu/p/9435818.html
https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_file_format )

来源:oschina
链接:https://my.oschina.net/u/4469818/blog/4279771