MySQL5.6 ERROR 1709(HY 000):Index column size too large問題の解決方法

2534 ワード

一、問題
mysql 5.6で次の問題が発生しました.
[ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.]

二、解決
ドキュメントの説明に従って
https://dev.mysql.com/doc/refman/5.6/en/create-index.html
Prefix support and lengths of prefixes (where supported) are storage engine dependent. For example, a prefix can be up to 767 bytes long for  InnoDB  tables or 3072 bytes if the  innodb_large_prefix  option is enabled. For  MyISAM  tables, the prefix length limit is 1000 bytes. 
https://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#sysvar_innodb_large_prefix
innodb_large_prefix
以上から分かるように、255文字以上の長さのフィールドにインデックスを作成する必要がある場合は、以下の3つのパラメータを変更する必要があります.
1.  innodb_file_format=barracuda
2.  innodb_file_per_table=true 3. ROW_FORMAT=DYNAMIC or COMPRESSED
パラメータの変更:
mysql> set global innodb_file_format = BARRACUDA;
mysql> set global innodb_large_prefix = ON;

テーブルを作成するには、ROW_FORMAT=DYNAMICのパラメータを追加する必要があります.
create table raw_log_meta_data(
       id bigint NOT NULL AUTO_INCREMENT,
       app_id varchar(64),
       user_id varchar(128),
       file_path varchar(512),
       device_id varchar(128),
       update_time DATETIME,
       PRIMARY KEY (id),
       UNIQUE KEY (user_id),
       UNIQUE KEY (file_path)
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected (0.29 sec)

原文:MySQLバージョン5.6.35 ERROR 1709(HY 000):Index column size too large