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
解决方法
我们可以在 AppServiceProvider.php 文件里的 boot 方法里设置一个默认值:
文件路径: /app/providers/AppServiceProvider.php,加上绿色部分即可
<?php 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); } /** * Register any application services. * * @return void */ public function register() { // } }
原文链接:https://www.cnblogs.com/richerdyoung/p/9167078.html
原文地址:https://www.cnblogs.com/erdongye/p/12683722.html
时间: 2024-10-11 12:54:45