Laravel Migration Error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

 

Step: 1

Update your /app/Providers/AppServiceProvider.php to contain:

use IlluminateSupportFacadesSchema;
/** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); }


Step: 2

in AppServiceProvider didn't work. Then editing the database.php file in config folder. Just edit 

/config/database.php

'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
to
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',

 

Step: 3

set the default database engine to 'InnoDB' on /config/database.php
'mysql' => [ ..., ..., 'engine' => 'InnoDB', ]

Leave a Reply