[报错:字符太长]SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long;

情景:执行php artisan migrate 报错
[报错:字符太长]SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long;_第1张图片

查阅了下资料说是mysql版本低,好吧mysql用phpstudy集成,可能会是有点低;

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

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()
    {
        //
    }
}

参考地址:https://laravel.com/docs/master/migrations#creating-indexes

你可能感兴趣的:(php,laravel)