mysql key was too long issue

 ̄綄美尐妖づ 提交于 2020-01-05 07:49:20

问题


i was trying to import my backup after ive change the charset to utf8 from latin1 , now during my import i got this error ERROR 1071 (42000) at line 2137: Specified key was too long; max key length is 1000 bytes try to change my.cnf and set all charset and connection to utf8 , but now luck , i dont want to get back to latin1 and i know this will fix the issue , but utf8 my gaol any clue ? i know latin 1 byte = 1 char and utf8 3 byte = 1 ..


回答1:


Can you switch from MyISAM to InnoDB, it seems to solve the prob..




回答2:


Although UTF-8 is not always 3 bytes for every character, MySQL is reserving 3 bytes per character for indexes.

If your application allows for it (i.e. it's not used in a UNIQUE KEY constraint), re-define / ALTER the table to use a prefix key of the appropriate length (i.e. < 1000/3).

CREATE TABLE my_table .... KEY my_field_20 (my_field(20));




回答3:


Use the --force option in your mysqldump command, it will ignore the error and continue the backup.



来源:https://stackoverflow.com/questions/4131206/mysql-key-was-too-long-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!