Specified key was too long;max key length is 767 bytes

https://blog.csdn.net/gladyoucame/article/details/16825779

https://blog.csdn.net/shaochenshuo/article/details/51064685

https://blog.csdn.net/bigdataf/article/details/78921409

关于mysql索引长度限制

From the manual at http://dev.mysql.com/doc/refman/5.6/en/create-table.html >>从5.6的官方文档中我们能找到如下双引号中解释

"For CHAR, VARCHAR, BINARY, and VARBINARY columns, indexes can be created that use only the leading part of column values, using col_name(length) syntax to specify an index prefix length.

...

Prefixes can be up to 1000 bytes long (767 bytes for InnoDB tables). Note that prefix limits are measured in bytes, whereas the prefix length in CREATE TABLE statements is interpreted as number of characters ...">>>对于myisam和innodb存储引擎,prefixes的长度限制分别为1000 bytes和767 bytes。注意prefix的单位是bytes,但是建表时我们指定的长度单位是字符。

A utf8 character can use up to 3 bytes. Hence you cannot index columns or prefixes of columns longer than 333 (MyISAM) or 255 (InnoDB) utf8 characters.  >>以utf8字符集为例,一个字符占3个bytes。因此在utf8字符集下,对myisam和innodb存储引擎创建索引的单列长度不能超过333个字符和255个字符

从上面可以看出,mysql 在创建单列索引的时候对列的长度是有限制的 myisam和innodb存储引擎下长度限制分别为1000 bytes和767 bytes。(注意bytes和character的区别)

2) 组合索引长度限制

对于innodb存储引擎,多列索引的长度限制如下:

每个列的长度不能大于767 bytes;所有组成索引列的长度和不能大于3072 bytes

问题解决方案

1) using col_name(length) syntax to specify an index prefix length.

alter table Table_Name add key(column_name(prefix_len));

create index index_name on Table_Name(column_name(prefix_len));

对列的前面某部分创建索引

2) 启用innodb_large_prefix参数

innodb_large_prefix >>启用innodb_large_prefix参数能够取消对于索引中每列长度的限制(但是无法取消对于索引总长度的限制)

启用innodb_large_prefix有如下前提条件:

Enable this option to allow index key prefixes longer than 767 bytes (up to 3072 bytes) for InnoDB tables that use the DYNAMIC and COMPRESSED row formats.(Creating such tables also requires the option values innodb_file_format=barracuda and innodb_file_per_table=true.) >>启用innodb_large_prefix必须同时指定innodb_file_format=barracuda,innodb_file_per_table=true,并且建表的时候指定表的row_format为dynamic或者compressed(mysql 5.6中row_format默认值为compact)

See Section 14.6.7, “Limits on InnoDB Tables” for the relevant maximums associated with index key prefixes under various settings. >>

For tables using the REDUNDANT and COMPACT row formats, this option does not affect the allowed key prefix length.

mysql 767 bytes_max key length is 767 bytes相关推荐

  1. mysql 报错 Specified key was too long; max key length is 767 bytes,开启系统变量:innodb_large_prefix

    mysql 报错 Specified key was too long; max key length is 767 bytes 当mysql数据库的字符集使用了utf8mb4,就很容易在执行建表sq ...

  2. Hive集成Mysql作为元数据时,提示错误:Specified key was too long; max key length is 767 bytes...

    在进行Hive集成Mysql作为元数据过程中.做全然部安装配置工作后.进入到hive模式,运行show databases.运行正常,接着运行show tables:时却报错. 关键错误信息例如以下: ...

  3. mysql导入报错1071_导入sql文件报错:1071 Specified key was too long; max key length is 767 bytes...

    一.背景 今天把服务器的数据库导出了一份sql文件,准备导入到本地,但是在导入的时候,报了个错: Syntax error or access violation: 1071 Specified ke ...

  4. mysql索引长度超过767bytes问题解决。Specified key was too long; max key length is 767 bytes

    mysql索引长度超过767bytes问题解决.   错误信息: Specified key was too long; max key length is 767 bytes MySQL的InnoD ...

  5. 一招解决MySql Specified key was too long; max key length is 767 bytes

    背景 今天迁移环境上阿里云的DMS建表 CREATE TABLE `xxl_job_registry` (   `id` int(11) NOT NULL AUTO_INCREMENT,   `reg ...

  6. mysql导入报错1071_mysql报错:Specified key was too long; max key length is 767 bytes | 吴老二...

    最近部署的mysql服务,在导入数据后,查询数据时提示:ERROR 1071 (42000) : Specified key was too long; max key length is 767 b ...

  7. Mysql执行脚本Specified key was too long; max key length is 767 bytes问题解决

    在用Navicate执行Mysql脚本的时候,一帆风顺. 因为生产库不允许远程操作,这个你懂的.所以没办法就把数据库脚本整体从本地导出来了,然后使用阿里云的数据导入功能. 在执行数据导入任务的时候,B ...

  8. Mysql报错:Specified key was too long; max key length is 767 bytes

    在执行mysql脚本时,报错:Specified key was too long; max key length is 767 bytes. 解决办法: 一.修改mysql的字符集为uft8 再次执 ...

  9. hive的Specified key was too long; max key length is 767 bytes问题解决

    把hive 的metadata配置成mysql,执行命令时报以下错误 hive> show tables; FAILED: Error in metadata: MetaException(me ...

最新文章

  1. LeetCode简单题之最常见的单词
  2. 浙大绘制首个地球微生物“社会关系”网络
  3. jQuery Mobile 1.1八大新特性介绍
  4. 居然不知道和的区别?
  5. 30 FI配置-财务会计-外币评估-准备外币评估的自动过账
  6. JS组件系列——BootstrapTable+KnockoutJS实现增删改查解决方案(一)
  7. m40型工业机器人_从工业机器人编程及应用到数控机床的安装维修,一次都学习了...
  8. 跟我学算法-集成算法
  9. 任意半径中值滤波(扩展至百分比滤波器)O(1)时间复杂度算法的原理、实现及效果。
  10. MongoDB 主从复制(主从集群 )
  11. python使用opencv进行身份证信息识别_基于opencv和tesseract实现身份证扫描件的身份证号码提取试验...
  12. excel取消按颜色排序_在Excel中按颜色排序
  13. oracle dba_hist_sql,从dba_hist_sqlstat视图中查找过去时段最占用资源的会话
  14. 校园消防vr模拟火灾逃生软件将火灾伤害全感官还原
  15. 客户体验管理 + ServiceNow:提供客户服务和体验的新标准
  16. 计算机表格怎样筛选男女,excel表格数据男女筛选-EXCEL表格中选择性别怎么做 就是如何做筛选 ,比如......
  17. 结构化数据和非结构化数据、半结构化数据的区别-归纳总结整理
  18. pythonocc 切完显示要要.Shape()
  19. 你,来到大学的第一眼
  20. python读取txt文件如何按数字分隔_python 读txt文件,按‘,’分割每行数据操作

热门文章

  1. 传Livy闭包head of empty list报错排查步骤
  2. 研究者们公布图像识别软件方面的最新进展
  3. 计算机组成原理实验课设:复杂指令模型计算机设计与实现
  4. 游戏美术设计师需要什么学历背景?主要做什么?
  5. 王力宏 有兴趣就看看
  6. 如何评估工时和开发计划
  7. 文件夹下的图片名字进行重命名--批量操作
  8. 利用Abel_Cain软件实现ARP欺骗
  9. python中的时间处理模块(二):datetime模块之timedelta类详解
  10. 成考本科计算机找工作有用吗,就是想问问成人高考的学历 到底有多大用,找工作好找么?...