Error: Specified key was too long; max key length is 1000 bytes

Viewed 23718

Error:

1071 - Specified key was too long; max key length is 1000 bytes 

CREATE TABLE `phppos_modules_actions` (
  `action_id` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
  `module_id` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
  `action_name_key` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
  `sort` INT NOT NULL ,
  PRIMARY KEY ( `action_id` , `module_id` )
) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_unicode_ci;

I know the error occurs because of 255x2x3 (3 bytes per character)

This doesn't happen on all installations. What setting can I change?

9 Answers

In my case, MySQL was started without InnoDB support. And during DB backup importing - tried to create MyISAM tables.

At the same time, no errors were shown in the console during MySQL restart.
Only when checked MySQL log file - found this.

BTW an error was related to innodb_log_file_size = 4G, only when changed it to innodb_log_file_size = 1G - InnoDB support was enabled.

Related