您的当前位置:首页Laravel 5.4: 提示Specified key was

Laravel 5.4: 提示Specified key was

2024-12-12 来源:哗拓教育

在laravel5,4上使用一个composer包的时候提示以下错误:

[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 users_email_unique(email))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

造成这个问题的原因一般是因为你的数据库版本低于5.7.7,解决办法。

修改AppServiceProvider.php文件

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}
显示全文