Larabel迁移文件时报SQLSTATE[42000]错误的解决方法
Laravel执行php artisan migrate命令时,报如错误的解决方法
Illuminate\Database\QueryException :
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long;
max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
解决方法
修改 app/Providers/AppServiceProvider.php文件中添加如下内容:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
public function register()
{
}
public function boot()
{
Schema::defaultStringLength(191);
}
}
修改部分
Schema::defaultStringLength(191);
本作品采用《CC 协议》,转载必须注明作者和本文链接
191
把默认引擎改成innodb就可以了