[Err] 1709 - Index column size too large. The maximum column size is 767 bytes.

描述

[Err] 1709 - Index column size too large. The maximum column size is 767 bytes.
[Err] CREATE INDEX `groups_1` ON `groups` (`name`);
 

   其实这个“ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes”错误是指超出索引字节的限制,并不是指字段长度限制。在官方文档“Limits on InnoDB Tables”有关于这方面的介绍、描述(详情请见参考资料):

 

解决方案

1:启用系统变量innodb_large_prefix

 

注意:光有这个系统变量开启是不够的。必须满足下面几个条件:

 

    1: 系统变量innodb_large_prefix为ON

    2: 系统变量innodb_file_format为Barracuda

    3: ROW_FORMAT为DYNAMIC或COMPRESSED

 

mysql> show variables like '%innodb_large_prefix%';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| innodb_large_prefix | ON    |
+---------------------+-------+
1 row in set (0.00 sec)

 

mysql> set global innodb_large_prefix=on;

 

mysql>  show variables like '%innodb_file_format%';
+--------------------------+-----------+
| Variable_name            | Value     |
+--------------------------+-----------+
| innodb_file_format       | Barracuda |
| innodb_file_format_check | ON        |
| innodb_file_format_max   | Barracuda |
+--------------------------+-----------+
3 rows in set (0.00 sec)

mysql> set global innodb_file_format=Barracuda;
Query OK, 0 rows affected (0.00 sec)


use zabbix_proxy

mysql> show table status from MyDB where name='TEST'\G;
*************************** 1. row ***************************
           Name: TEST
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 0
 Avg_row_length: 0
    Data_length: 16384
Max_data_length: 0
   Index_length: 16384
      Data_free: 0
 Auto_increment: NULL
    Create_time: 2018-09-20 13:53:49
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options: 
        Comment: 
 
mysql>  ALTER TABLE TEST ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
mysql> show table status from MyDB where name='TEST'\G;
*************************** 1. row ***************************
           Name: TEST
         Engine: InnoDB
        Version: 10
     Row_format: Dynamic
           Rows: 0
 Avg_row_length: 0
    Data_length: 16384
Max_data_length: 0
   Index_length: 16384
      Data_free: 0
 Auto_increment: NULL
    Create_time: 2018-09-20 14:04:05
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options: row_format=DYNAMIC
        Comment: 
1 row in set (0.00 sec)
 
ERROR: 
No query specified
 
mysql> ALTER TABLE TEST MODIFY CODE_VALUE1 VARCHAR(350);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

 

 

 

 

参考链接 https://www.cnblogs.com/kerrycode/p/9680881.html

 

 

Index column size too large. The maximum column size is 767 bytes. 这个错误通常在MySQL数据库上建立索引时出现。具体原因是因为MySQL Innodb引擎表索引字段长度的限制是767字节。所以当对于多字节字符集的大字段(或者多字段组合索引)创建索引时,会出现这个错误。 解决这个问题的方法有几种。一种方法是减少索引字段的长度,比如将字段长度缩短到767字节以下。另一种方法是使用前缀索引,通过只索引字段的前几个字符来解决。还有一种方法是更改数据库的字符集,将字符集改为utf8或者latin等较小的字符集。 如果你使用的是MySQL 5.7.7或更高版本,还可以通过修改配置文件来解决这个问题。在配置文件中添加以下内容: ``` <span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [提要:自托管的RSS阅读器-带有Symfony的API-独立的html客户端-Google阅读器替代](https://download.csdn.net/download/weixin_42127748/15095482)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [解决MySQL报 index column size too large. the maximum column size is 767 bytes 问题](https://blog.csdn.net/weixin_52005792/article/details/118157681)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Index column size too large. The maximum column size is 767 bytes.](https://blog.csdn.net/m0_71124383/article/details/129809980)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值