解决Laravel错误1071 Specified key was too long的多种方法
Posted callback
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决Laravel错误1071 Specified key was too long的多种方法相关的知识,希望对你有一定的参考价值。
If you are using MariaDB or an older version of mysql, you need to place this code in your AppServiceProvider.php:
use IlluminateSupportFacadesSchema; public function boot() { Schema::defaultStringLength(191); }
Inside config/database.php
, replace this line for mysql
‘engine‘ => null‘,
with
‘engine‘ => ‘InnoDB ROW_FORMAT=DYNAMIC‘,
Instead of setting a limit on your string lenght.Change database.php which is in config folder where it says
‘charset‘ => ‘utf8mb4‘, ‘collation‘ => ‘utf8mb4_unicode_ci‘,
I changed these to
‘charset‘ => ‘utf8‘, ‘collation‘ => ‘utf8_unicode_ci‘,
以上是关于解决Laravel错误1071 Specified key was too long的多种方法的主要内容,如果未能解决你的问题,请参考以下文章
laravel报错1071 Specified key was too long; max key length is 1000 bytes
laravel5.5 Syntax error or access violation: 1071 Specified key was too long
laravel migrate时报错:Syntax error or access violation: 1071 Specified key was too long; max key length
Laravel 5.4 migrate报错:Syntax error or access violation: 1071 Specified key was too long; max key len