laravel: Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation...

4424012-901b210beb0ec6a2.png
Use mysql version 8.0

Use php artisan migratethe command promptIlluminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes

4424012-161c08be0a2464c4.png
image.png

solve

Amendment 1 \ app \ Providers below AppServiceProvider.php

public function boot()
    {
        Schema::defaultStringLength(191);
    }

If errors are reported, added the headuse Illuminate\Support\Facades\Schema;

4424012-81aac71b421e8d5b.png
image.png

2 modified /config/database.php

'engine' => null'改成 
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',

3 Empty Cache

php artisan cache:clear
php artisan config:clear

4 executionphp artisan migrate

4424012-49c90860266004a8.png
Get

Reproduced in: https: //www.jianshu.com/p/651ccb3f3109

Guess you like

Origin blog.csdn.net/weixin_34124939/article/details/91330691