4
votes

In Connection.php line 647:

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table users add uni que users_email_unique(email))

In Connection.php line 449:

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes. . . .

How can i solve this??

When i want to migrate default migrations in CMD this error happens.

2
Set a shorter key length? You've set your email field to a really long value? Can you post the table structure?G_V
well this is because mySQL indexes are only available for string that has length lower than 192 .. you may want to change the defaultStringLength ..Demonyowh

2 Answers

4
votes

Add this to your AppServiceProvider.php file:

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

This article by Laravel News explains it

2
votes

For Laravel 5.4 add code in AppServiceProvider.php

use Illuminate\Support\Facades\Schema;

and in boot

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