问题

create table: Specified key was too long; max key length is 767 bytes
 

原因

数据库表采用utf8编码,其中varchar(255)的column进行了唯一键索引
而mysql默认情况下单个列的索引不能超过767位(不同版本可能存在差异)
 
于是utf8字符编码下,255*3 byte 超过限制
 

解决

1  使用innodb引擎;
2  启用innodb_large_prefix选项,将约束项扩展至3072byte;
3  重新创建数据库;
 
my.cnf配置:
default-storage-engine=INNODB
innodb_large_prefix=on
 
 
一般情况下不建议使用这么长的索引,对性能有一定影响;
 
参考文档:
 

mysql 索引过长1071-max key length is 767 byte的更多相关文章

  1. 索引长度过长 ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes

    1.发现问题 今天在修改innodb表的某个列的长度时,报如下错误: alter table test2 modify column id varchar(500); ERROR 1071 (4200 ...

  2. 【转】mysql 索引过长1071-max key length is 767 byte

    问题 create table: Specified key was too long; max key length is 767 bytes 原因 数据库表采用utf8编码,其中varchar(2 ...

  3. Navicat for Mysql中错误提示索引过长1071-max key length is 767 byte

    1.建用户信息表 tb_person_info create table tb_person_info( user_id int(10) auto_increment, `name` varchar( ...

  4. MySQL 报错:[Err] 1071 - Specified key was too long; max key length is 767 bytes

    [Err] 1071 - Specified key was too long; max key length is 767 bytes 这个会出现在MySQ5.7以下版本 因为没有启用innodb_ ...

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

    今天在MySQL 5.6版本的数据库中修改InnoDB表字段长度时遇到了"ERROR 1071 (42000): Specified key was too long; max key le ...

  6. laravel migrate时报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

    今天在学习laravel的路由模型绑定时,在按照文档执行php artisan migrate时报错. In Connection.php line 664: SQLSTATE[42000]: Syn ...

  7. django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')

    环境介绍 Django (2.1)  Python 3.5.5 mysqlclient (1.4.2.post1) Mysql 5.6.28 RHEL 7.3 在migrate时候报错 model代码 ...

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

    ref: https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-7 ...

  9. 关于MySQL字符集问题:Specified key was too long; max key length is 767 bytes

    [文章来源]http://blog.csdn.net/cindy9902/article/details/6215769 MySQL: ERROR 1071 (42000): Specified ke ...

随机推荐

  1. apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName的解决

    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ...

  2. C# delegate & event

    public delegate void MyDelegate(string mydelegate);//声明一个delegate对象 //实现有相同参数和返回值的函数        public v ...

  3. 4 Values whose Sum is 0_upper_bound&&ower_bound

    Description The SUM problem can be formulated as follows: given four lists A, B, C, D of integer val ...

  4. Cash Machine_多重背包

    Description A Bank plans to install a machine for cash withdrawal. The machine is able to deliver ap ...

  5. The Triangle_DP

    ime Limit: 1000MS   Memory Limit: 10000K Total Submissions: 45620   Accepted: 27612 Description 73 8 ...

  6. buildroot httpd php

    /******************************************************************** * buildroot httpd php * 说明: * ...

  7. 在用的vim插件

    The-NERD-tree  https://github.com/vim-scripts/The-NERD-tree 在vim中也可以有目录树的,如果要打开当前文件夹下的其他文件的话也可以很方便的进 ...

  8. Sublime Text 2 安装主题的方法

    主题下载 下载一个主题,例如: https://github.com/hyspace/st2-reeder-theme 里面起作用的文件有两个: Reeder.sublime-theme Earths ...

  9. Bean实例化(Spring源码阅读)-我们到底能走多远系列(33)

    我们到底能走多远系列(33) 扯淡: 各位:    命运就算颠沛流离   命运就算曲折离奇   命运就算恐吓着你做人没趣味   别流泪 心酸 更不应舍弃   ... 主题: Spring源码阅读还在继 ...

  10. LINQ 按多个字段排序

    多字段排序 添加到 LINQ 查询结果中的Take()扩展方法用于提取前 个结果: private static void Ordering() { var racers = (from r in F ...