MySQL错误“Specified key was too long; max key length is 1000 bytes”的解决办法

转载 2018年04月16日 11:29:19
经过查询才知道,是Mysql的字段设置的太长了,于是我把这两个字段的长度改了一下就好了。 

建立索引时,数据库计算key的长度是累加所有Index用到的字段的char长度后再按下面比例乘起来不能超过限定的key长度1000: 
latin1 = 1 byte = 1 character 
uft8 = 3 byte = 1 character 
gbk = 2 byte = 1 character 
举例能看得更明白些,以GBK为例: 
CREATE UNIQUE INDEX `unique_record` ON reports (`report_name`, `report_client`, `report_city`); 
其中report_name varchar(200), report_client varchar(200), report_city varchar(200) 
(200 + 200 +200) * 2 = 1200 > 1000,所有就会报1071错误,只要将report_city改为varchar(100)那么索引就能成功建立。 
如果表是UTF8字符集,那索引还是建立不了。

laravel错误1071 Specified key was too long; max key length is 1000 bytes

Laravel 5.4默认使用utf8mb4字符编码,而不是之前的utf8编码。因此运行php artisan migrate 会出现如下错误:[Illuminate\Database\QueryEx...
  • qq_15766181
  • qq_15766181
  • 2017-05-03 17:02:41
  • 5331

ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes

1.版本1)操作系统 cat /etc/issuecat /etc/issueCentOS release 6.6 (Final)Kernel \r on an \m cat /proc/versio...
  • shaochenshuo
  • shaochenshuo
  • 2016-04-05 17:30:11
  • 9138

关于Django出现Specified key was too long; max key length is 767 bytes的解决办法

最近在开发Django网站,但是当我从腾讯蓝鲸上面将代码签到本地运行的时候,系统提示运行python manage.py migrate来进行数据库的同步,但是运行时一直出现OperationalEr...
  • IT_DREAM_ER
  • IT_DREAM_ER
  • 2016-08-16 16:29:15
  • 5020

Hive 创建表提示"Specified key was too long; max key length is 767 bytes"解决办法

Hive> CREATE TABLE dummy(value STRING); FAILED: Execution Error, return code 1 from org.apache.hado...
  • KelJony
  • KelJony
  • 2015-02-01 15:40:31
  • 7731

MySQL错误“Specified key was too long; max key length is 1000 bytes”的解决办

MySQL错误“Specified key was too long; max key length is 1000 bytes”的解决办法 阅读:13次   时间:2011-12-02 05:16...
  • wocjj
  • wocjj
  • 2012-03-31 12:52:08
  • 16819

Hive 创建表报"Specified key was too long; max key length is 767 bytes" 错误

Hive元数据库使用MySQL数据库,在使用Hive创建表的时候,报了以下错误: hive> create table base ( id int, name string, address...
  • NIITYZU
  • NIITYZU
  • 2015-06-23 15:43:28
  • 3003

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

当hive安装完成后,在hive中执行show table等任何命令,都会报以下错: [grid@racdb ~]$ hive Logging initialized using configura...
  • lichangzai
  • lichangzai
  • 2015-10-18 19:30:56
  • 1491

[MySQL] specified key was too long max key length is 767bytes

一、问题描述描述:创建唯一索引时,数据库报错: specified key was too long max key length is 767bytes 数据库版本:5.5.22-log引擎: ...
  • u012099869
  • u012099869
  • 2016-12-22 15:29:37
  • 1525

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

#1071 - Specified key was too long; max key length is 767 bytes
  • angelina_zf
  • angelina_zf
  • 2017-08-16 09:43:02
  • 435

hive执行命令Specified key was too long; max key length is 767 bytes 问题

在进入Hive后可以show databases; 但create table, show tables;等命令都报错,如下: [ihadoop@Master ~]$ cd /home/ihadoo...
  • zlx510tsde
  • zlx510tsde
  • 2015-11-19 10:04:42
  • 2825
收藏助手
不良信息举报
您举报文章:MySQL错误“Specified key was too long; max key length is 1000 bytes”的解决办法
举报原因:
原因补充:

(最多只允许输入30个字)