Syntax error or access violation: 1071 Specified key was too long

Posted 1 year ago by Demers94


I've just upgraded to Laravel 5.4 and created my first project with it. When I first try to migrate the database, I get this error :

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

I can fix this by going in the migration for the users table, and manually specifying the max-length of the email field, like so :

$table->string('email', 250)->unique();

If I run php artisan migrate again, it will work for the users table, but will fail for the password reset table. I have to do the same thing for the email field in that migration.

Has anyone else encountered this issue? It was working fine before with 5.3.

I'm running Windows 10 and using HeidiSQL to create my database, like I've always used before.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.