Specified key was too long; max key length is 767 bytes
Index column size too large. The maximum column size is 767 bytes
列、索引長度超出了限制大小:
innode引擎-索引的每列最長不能超過767bytes,組成索引的列長度和不能大於3072bytes
myisam引擎-索引的每列最長不能超過1000bytes;,組成索引的列長度和不能大於1000bytes
字符對應字節數:
utf8 3字節 utf8mb4 4字節
解決辦法:
檢查數據庫是否被限制了索引的大小
show variables like 'innodb_large_prefix';
如果是OFF的話設置成ON:
SET GLOBAL INNODB_LARGE_PREFIX = ON;
檢查當前的innodb_file_format引擎格式類型
show variables like 'innodb_file_format';
如果不是BARRACUDA設置:
SET GLOBAL innodb_file_format = BARRACUDA
創建語句後面添加:
CREATE TABLE TEST (...) ROW_FORMAT=DYNAMIC default charset utf8mb4;