Erreur 1071 de mysql: Specified key was too long; max key length is 1000 bytes
Bonjour,
Après avoir configuré MariaDB pour être en UTF8MB4, je n'ai pas pu installer un plugin (comme il y a aussi un bug SVP, je vais faire un autre ticket spécifique). Pour être précis, un table du plugin n'a pas été créée et sql.log contient :
2019-05-25 16:23:59 78.205.175.37 (pid 16091) :Pri:ERREUR: Erreur 1071 de mysql: Specified key was too long; max key length is 1000 bytes in ecrire/base/create.php L73 [sql_create(),creer_ou_upgrader_table(),alterer_base(),maj_tables(),serie_alter(),maj_while(),maj_plugin(),referer_spam_upgrade(),spip_plugin_install(),plugins_installer_dist(),installer_plugin(),do_install(),do_action(),one_action(),action_actionner_dist(),traiter_appels_actions()] CREATE TABLE IF NOT EXISTS `mutu_pro2spipf126`.spip_referer_spam ( date DATE NOT NULL, referer VARCHAR (255) , PRIMARY KEY (referer)) ENGINE=MyISAM
La documentation sur ce sujet est abondante. Ceci m'a semblé un bon résumé du problème : https://stackoverflow.com/questions/6172798/mysql-varchar255-utf8-is-too-long-for-key-but-max-length-is-1000-bytes Et la solution générale consiste à faire un index de seulement 191 : https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-conversion.html :
In an InnoDB table that uses COMPACT or REDUNDANT row format, these column and index definitions are legal: col1 VARCHAR(500) CHARACTER SET utf8, INDEX (col1(255)) To use utf8mb4 instead, the index must be smaller: col1 VARCHAR(500) CHARACTER SET utf8mb4, INDEX (col1(191))
Modification effectuée par JamesRezo