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

导致这个问题的原因索引的字段都太长了,mysql受不了,解决方法就是,让mysql支持比较长的索引,然后在插入表的时候,添加ROW_FORMAT=DYNAMIC ,自动格式化索引。

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

查看数据库信息


1

2

3

4

5

6

7

8

show variables like ‘innodb_large_prefix‘

show variables like ‘innodb_file_format‘;

--修改最大索引长度限制

set global innodb_large_prefix=1;

set global innodb_file_format=BARRACUDA;

-- 添加

set global innodb_file_format_max=BARRACUDA;

2、修改插入sql的语句添加ROW_FORMAT=DYNAMIC


1

2

3

4

5

6

create table idx_length_test_02

(

  id int auto_increment primary key,

  name varchar(255)

)

ROW_FORMAT=DYNAMIC default charset utf8mb4;

原文地址:https://www.cnblogs.com/wang-yaz/p/10942869.html

时间: 2024-08-01 03:24:30

Mysql Specified key was too long; max key length is 767 bytes的相关文章

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

在进行Hive集成Mysql作为元数据过程中,做完所有安装配置工作后,进入到hive模式,执行show databases:执行正常,接着执行show tables:时却报错. 关键错误信息如下: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes) 具体操作信息如下: hive> show databases; OK

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

Specified key was too long; max key length is 767 bytes 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息. 异常详细信息: MySql.Data.MySqlClient.MySqlException: Specified key was too long; max key length is 767 bytes 给Context增加如下的注解 [DbConfigu

hive异常:创建MySQL时Specified key was too long; max key length is 1000 bytes

2015-11-13 14:44:44,681 ERROR [main]: DataNucleus.Datastore (Log4JLogger.java:error(115)) - An exception was thrown while adding/validating class(es) : Specified key was too long; max key length is 1000 bytescom.mysql.jdbc.exceptions.jdbc4.MySQLSynta

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

启动hive后运行:SHOW TABLES 报错 hive> show tables; FAILED: Error in metadata: MetaException(message:Got exception: javax.jdo.JDODataStoreException An exception was thrown while adding/validating class(es) : Specified key was too long; max key length is 767

执行nova-manage db sync时出错,提示’Specified key was too long; max key length is 1000 bytes’

执行nova-manage db sync时出错: 2012-03-24 14:07:01 CRITICAL nova [-] (OperationalError) (1071, ‘Specified key was too long; max key length is 1000 bytes’) ‘\nCREATE TABLE user_project_association (\n\tcreated_at DATETIME, \n\tupdated_at DATETIME, \n\tdele

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

报错信息如下: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:javax.jdo.JDODataStoreException: An exception was thrown while adding/validating class(es) : Specified key was too long; max key length

hive报错: Specified key was too long; max key length is 767 bytes

DataNucleus.Datastore (Log4JLogger.java:error(115)) - An exception was thrown while adding/validating class(es) : Specified key was too long; max key length is 767 bytescom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too

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 length is 767 bytes"错误,第一次遇到这个错误,遂花了点学习.研究过.总结这个问题. 我们先来创建一个测试表,构造这样的错误. mysql> use MyDB; Reading table information for completion of table and colum

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

Laravel 默认使用utf8mb4字符编码,而不是的utf8编码.因此运行php artisan migrate会出现如下错误: [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique