当前位置:Gxlcms > 数据库问题 > laravel migrate时报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

laravel migrate时报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

时间:2021-07-01 10:21:17 帮助过:6人阅读

在按照文档执行php artisan migrate时报错。

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`))

  解决方法

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

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

  

laravel migrate时报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

标签:syntax   bash   code   cat   ESS   access   alter   state   lte   

人气教程排行