美文网首页
Laravel 5.4: 提示Specified key was

Laravel 5.4: 提示Specified key was

作者: 张晓刚_云字节 | 来源:发表于2017-11-02 10:28 被阅读67次

在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);
}

相关文章

网友评论

      本文标题:Laravel 5.4: 提示Specified key was

      本文链接:https://www.haomeiwen.com/subject/fykopxtx.html