MySQL 报错:[Err] 1071 - Specified key was too long; max key length is 767 bytes
[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
-----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------
(蓝奏云官网有些地址失效了,需要把请求地址lanzous改成lanzoux才可以)