laravel5.5使用passport运行migrate命令出现Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytesLaravel错误。
Laravel 5.5默认使用utf8mb4字符编码,而不是之前的utf8编码。因此运行PHP artisan migrate会出现如下错误:
解决办法
找到app\Providers\AppServiceProvider.PHP文件夹:
# 引入Schemause Illuminate\Support\Facades\Schema;# 在boot中添加Schema::defaultStringLength(191);
完整例子为:
<?PHPnamespace 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); } /** * Register any application services. * * @return void */ public function register() { // } }