问题
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