code1521

Laravel 1071 Specified key was too long

 

出现错误

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter
table `users` add unique `users_email_unique`(`email`))

解决方法:参考了

可以在 AppServiceProvider.php 文件(此文件在app/Providers/下)里的 boot 方法里设置一个默认值:

use Illuminate\Support\Facades\Schema;
public function boot()
{
    //
    Schema::defaultStringLength(191);
}

 参考:https://blog.csdn.net/sinat_33801009/article/details/80817486


posted on 2019-04-27 11:02  code1521  阅读(171)  评论(0编辑  收藏  举报

导航