Laravel 6 – 1071 Specified key was too long; max key length is 767 bytes

Laravel 6 – 1071 Specified key was too long; max key length is 767 bytes

When we migration of the table after the installation of the latest laravel at that time we face this type of error.

Because it’s not 520 bytes, but rather, 2080 bytes, which far exceeds 767 bytes, so we are facing this type of error.

Syntax error or access violation, #1071 – Specified key was too long; max key length is 767 bytes, PHP artisan migrate command error, long max key length is 767 bytes, syntax error or access violation 1071, MySQL error

Now. let’s go we will solve the above error. first, open the AppServiceProvider.php file from the app/Providers/ directory. after then we will load the schema “use Illuminate\Support\Facades\Schema;” on the top header and set the “Schema::defaultStringLength(191);” into boot method.

You can see the below code, therefore, then you can better understand.

After the above changes, you can again migrate the table and then it will be successfully migrated.
Read Also
Laravel 6 Image Upload Tutorial Example
Laravel 6 Ajax Image Upload Example Tutorial
Laravel 6 Multiple Image Upload Example Tutorial

Please follow and like us: