Demers94
2460
43
General

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

Posted 2 years ago by Demers94

Hi,

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.

Reply to

Use Markdown with GitHub-flavored code blocks.