MYSQL Index Key Length 1071 – Specified key was too long; max key length is 3072 bytes

MySQL index key length

In the development, two varchar 1000 fields are associated. As a MySQL index white, I directly add a normal index to the table. This will report an error, saying that the length of my index is too long. Search on the Internet is to change the MySQL configuration file. By chance, I saw an article sent by a big man, and I knew that the index length of MySQL was such a usage.

Error reported by MySQL: 1071 – specified key was too long; max key length is 3072 bytes

SELECT
 ROUND(SUM(LENGTH(`school_unit_title`)<10)*100/COUNT(`school_unit_title`),2) AS pct_length_10,
 ROUND(SUM(LENGTH(`school_unit_title`)<20)*100/COUNT(`school_unit_title`),2) AS pct_length_20,
 ROUND(SUM(LENGTH(`school_unit_title`)<50)*100/COUNT(`school_unit_title`),2) AS pct_length_50,
 ROUND(SUM(LENGTH(`school_unit_title`)<80)*100/COUNT(`school_unit_title`),2) AS pct_length_80,
 ROUND(SUM(LENGTH(`school_unit_title`)<100)*100/COUNT(`school_unit_title`),2) AS pct_length_100
FROM `z_school_unit`;

Read More: