环境
Laravel 5.8
Mysql 5.6
PHP 7.1
报错
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
(email
))
解决方法
在 AppServiceProvider.php 文件里的 boot 方法里设置一个默认值
文件路径: /app/providers/AppServiceProvider.php
use Illuminate\Support\Facades\Schema;
public function boot()
{
//
Schema::defaultStringLength(191);
}