MySQL出现Specified key was too long max key length is 767 bytes

image

解决办法:

#登录MySQL
mysql -h192.168.20.101 -uroot -p
#切换到数据
use mydb
# 查看 innodb_large_prefix
SHOW variables like ‘innodb_large_prefix’;
#开启innodb_large_prefix
set global innodb_large_prefix = ON;
set global innodb_file_format = BARRACUDA;

如果表字段过多最好要控制每个字段的字符长度,如果某个字段字段长度不明确应该定义为text,否则也会出现该问题。也有可能是是你定义在的索引的字段超出了预定字符长度

参考:

1.Specified key was too long; max key length is 767 bytes

2.Specified key was too long; max key length is 767 bytes

如果觉得我的文章对你有用,请随意赞赏