Mysql5.6版本之Specified key was too long; max key length is 767 bytes

ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes

 

 查看数据库信息

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

create table idx_length_test_02
(
  id int auto_increment primary key,
  name varchar(255)
) ROW_FORMAT=DYNAMIC default charset utf8mb4;

 

 

参考文章

https://help.aliyun.com/knowledge_detail/41707.html

posted @ 2022-09-05 16:57  民宿  阅读(219)  评论(0编辑  收藏  举报