Mysql Specified key was too long; max key length is 767 bytes
Posted wang-yaz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql Specified key was too long; max key length is 767 bytes相关的知识,希望对你有一定的参考价值。
导致这个问题的原因索引的字段都太长了,mysql受不了,解决方法就是,让mysql支持比较长的索引,然后在插入表的时候,添加ROW_FORMAT=DYNAMIC ,自动格式化索引。
ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
查看数据库信息
1
2
3
4
5
6
7
8
|
show variables like ‘innodb_large_prefix‘ ; show variables like ‘innodb_file_format‘ ; --修改最大索引长度限制 set global innodb_large_prefix=1; set global innodb_file_format=BARRACUDA; -- 添加 set global innodb_file_format_max=BARRACUDA; |
2、修改插入sql的语句添加ROW_FORMAT=DYNAMIC
1
2
3
4
5
6
|
create table idx_length_test_02 ( id int auto_increment primary key , name varchar (255) ) ROW_FORMAT= DYNAMIC default charset utf8mb4; |
以上是关于Mysql Specified key was too long; max key length is 767 bytes的主要内容,如果未能解决你的问题,请参考以下文章
MySQL双字符主键过长 Specified key was too long; max key length is 767 bytes
Mysql Specified key was too long; max key length is 767 bytes
mysql: Specified key was too long; max key length is 767 bytes
解决Code First MySql数据库 Specified key was too long; max key length is 767 bytes异常
hive异常:创建MySQL时Specified key was too long; max key length is 1000 bytes
MySQL错误“Specified key was too long; max key length is 1000 bytes”