Laravel 5.4: Specified key was too long

If you’re running an earlier version of mysql than 5.7.7 you may get this error.

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

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

To solve this, edit your AppServiceProvider.php file and set the string length in the boot method.

 

Leave a Reply

Your email address will not be published. Required fields are marked *