mysql报错:Specified key was too long; max key length is 767 bytes

avatar 2020年11月5日18:01:11 评论 2,603 次浏览

最近部署的mysql服务,在导入数据后,查询数据时提示:ERROR 1071 (42000) : Specified key was too long; max key length is 767 bytes ,原本以为是key的值过长导致的,原来就是过长导致的,解决方法就是修改一下mysql的配置,进入mysql修改一下系统的变量,首先看一下mysq的索引长度限制是否打开,如果没有就开启就开启一下,下面是进入mysql后操作内容:

show variables like '%innodb_large_prefix%';//查看是否开启
set global innodb_large_prefix=on;//如果没有开启设置开启
show variables like '%innodb_file_format%';//查看file格式
set global innodb_file_format=Barracuda;//设置格式
set global innodb_file_format_max=Barracuda;//设置格式
row_format=DYNAMIC或COMPRESSED ;//设置格式

索引设置格式根据自己的需求可以设置innodb_file_format或者innodb_file_format_max,两者的区别是在于索引的压缩,这里就不解释了。

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: