Syntax error or access violation: Specified key was too long;
Laravel 5.4 made a change to the default database character set, and it’s now utf8mb4 which includes support for storing emojis. This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything.
For those running MariaDB or older versions of MySQL you may hit this error when trying to run migrations:
Here is how to solve syntax error or access violation: 1071 specified key was too long; max key length is 767 bytes error.
Open app/providers/EvenetServiceProvider.php
Now replace the code with the below-mentioned code.
namespace AppProviders;
use IlluminateSupportFacadesSchema;
use IlluminateSupportFacadesEvent;
use IlluminateFoundationSupportProvidersEventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'AppEventsEvent' => [
'AppListenersEventListener',
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
Schema::defaultStringLength(191);
//
}
}
Look at this line
Schema::defaultStringLength(191);
defaultStringLength(191);


Leave a Reply