今天在学习laravel的路由模型绑定时,在按照文档执行php artisan migrate时报错. In Connection.php line 664: 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 `users_email_unique`(…
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S QL: alter table `users` add unique `users_email_unique`(`email`)) [PDOException] SQLSTA…
Laravel 默认使用utf8mb4字符编码,而不是的utf8编码.因此运行php artisan migrate会出现如下错误: [Illuminate\Database\QueryException] SQLSTATE[]: Syntax error or access violation: Specified key was too long; max key length is bytes (SQL: alter table users add unique users_email_u…
操作重现: 法1:新建连接——>新建数据库——>右键数据库导入脚本——>提示:Specified key was too long; max key length is 767 bytes 法2:新建连接——>新建数据库——>新增查询——>复制脚本中的内容,运行——>提示:Specified key was too long; max key length is 767 bytes 原因: MySQL的varchar主键只支持不超过768个字节 或者 768/2=…
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…
Using innodb_large_prefix to avoid ERROR 1071 单列索引限制上面有提到单列索引限制767,起因是256×3-1.这个3是字符最大占用空间(utf8).但是在5.5以后,开始支持4个字节的uutf8.255×4>767, 于是增加了一个参数叫做 innodb_large_prefix.这个参数默认值是OFF.当改为ON时,允许列索引最大达到3072. 联合索引3072我们知道InnoDB一个page的默认大小是16k.由于是Bt…