[Err] 1071 - Specified key was too long; max key length is 767 bytes
这个会出现在MySQ5.7以下版本 因为没有启用innodb_large_prefix
MySQL 5.6:
MySQL 5.7:
简单办法:如果要求不是很高 ,也可以直接把表字段varchar(255)设置为varchar(64)
另外一种:修改配置 (重启服务会失效)
mysql> show variables like '%innodb_large_prefix%'; +---------------------+-------+ | Variable_name | Value | +---------------------+-------+ | innodb_large_prefix | OFF | +---------------------+-------+ 1 row in set mysql> set global innodb_large_prefix=on; Query OK, 0 rows affected mysql> show variables like '%innodb_large_prefix%'; +---------------------+-------+ | Variable_name | Value | +---------------------+-------+ | innodb_large_prefix | ON | +---------------------+-------+ 1 row in set