MySQL Error: [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

This will appear on mysq5 7 or below because InnoDB is not enabled_large_prefix

MySQL 5.6:

MySQL 5.7:

Simple method: if the requirement is not very high, you can also directly set the table field varchar (255) to varchar (64)

The other is to modify the configuration (the service will become invalid after restarting)

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

Similar Posts: