laravel 错误

2017-09-25  本文已影响0人  HaRun
[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`))     

修复方法:

在App\Providers\AppServiceProvider.php文件中boot()添加:

<?php
namespace App\Providers;

use Illuminate\Support\Facades\Schema;//记得添加这个类哦
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);//添加此代码
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
上一篇下一篇

猜你喜欢

热点阅读