![4424012-901b210beb0ec6a2.png](https://upload-images.jianshu.io/upload_images/4424012-901b210beb0ec6a2.png)
使用mysql版本为8.0
使用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
![4424012-161c08be0a2464c4.png](https://upload-images.jianshu.io/upload_images/4424012-161c08be0a2464c4.png)
image.png
解决
1 修改\app\Providers下面AppServiceProvider.php
public function boot()
{
Schema::defaultStringLength(191);
}
如果报错,头部添加use Illuminate\Support\Facades\Schema;
![4424012-81aac71b421e8d5b.png](https://upload-images.jianshu.io/upload_images/4424012-81aac71b421e8d5b.png)
image.png
2 修改
/config/database.php
'engine' => null'改成
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
3 清空缓存
php artisan cache:clear
php artisan config:clear
4 在执行php artisan migrate
![4424012-49c90860266004a8.png](https://upload-images.jianshu.io/upload_images/4424012-49c90860266004a8.png)
搞定
转载于:https://www.jianshu.com/p/651ccb3f3109