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

在按照文档执行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的dd函数不生效怎么办
看不懂laravel文档咋办
安装laravel框架出现command怎么办
Laravel开发API怎么使用事务
laravel怎么构建复杂查询条件
laravel如何实现防止被下载