One day I install Laravel 5.6 When I am going to create a migration for the Laravel application. Then I run Laravel migration command I got an error like 1071 specified key was too long max key length is 767 bytes. I find the solution why I got Laravel 1071 specified key was too long error when I run the migration.
Since Laravel 5.4 change the default database character set to "utf8mb4" for includes support for storing emojis. This only affects If you running MariaDB or older versions of MySQL. You may hit this error when you are running migration command.
Illuminate\Database\QueryException : SQLSTATE: 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: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
As per Laravel 5.4.* documentation, You need to set default string length on Boot method for the resolving this issue.
Laravel 5.6 - 1071 specified key was too long
First of all, Open the App Service Provider at "app/Providers/AppServiceProvider.php" then follow the below steps.
class AppServiceProvider extends ServiceProvider
* Bootstrap any application services.
* @return void
public function boot()
* Register any application services.
* @return void
public function register()
After, applying that solution everything is working fine. Still, if you face any issue write the command below.