Tuesday 19 May 2020

MySQL: Fix Error 1071 "Specified key was too long"

MySQL/MariaDB Error 1071 when try to import SQL File:

#1071 - Specified key was too long; max key length is 767 bytes
Sometime error is "max key length is 1000 bytes"

Reason:
From MySQL 5.6 and MariaDB 10.2.2 InnoDB File Format default is Barracudar. Barracudar is newer file type ,support many new format types (DYNAMIC and COMPRESSED). But in older version of MySQL or MariaDB default InnoDB File Format is still Antelope. So if you want to import a database using Barracudar(exported from newer version), you also need to change the current file format to Barracudar.

Solved:
To do that, run the following command in the Mysql command line (Root account is required):

SET GLOBAL innodb_file_format = Barracuda;
SET GLOBAL innodb_file_per_table = on;
SET GLOBAL innodb_default_row_format = dynamic;
SET GLOBAL innodb_large_prefix = 1;
SET GLOBAL innodb_file_format_max = Barracuda;
FLUSH PRIVILEGES;
Done ! The problem has been solved, you can try imoport SQL file again.

Tip: You can run Mysql command line from linux terminal or run Query in Navicat, PHPMyadmin ....

mysql -h localhost -u root -p
Refer: https://dev.mysql.com/doc/refman/5.6/en/innodb-file-format-enabling.html

0 nhận xét:

Post a Comment