In the documentation of Laravel 5.4 and above version, they have clearly written that they have used “utf8mb4” character set by default in order to support for emojis in the database. They also have informed us that this error occurs on MySQL older version than 5.7.7 and MariaDB older than 10.2.2. Along with information of error, we also can find solution of that error. According to their documentation, we should manually configure default string length calling a function inside AppServiceProvider.

First, go to App>>Providers and open AppServiceProvider. Inside boot function, copy and paste the following code.

Schema::defaultStringLength(191);

Note: Don’t forget to include¬†use Illuminate\Support\Facades\Schema; above the class AppServiceProvider

Now your code will be like this.

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
}

}

After implementing above code, now application will work fine. If you are still seeing the same error, please comment below and let us know. We will try to assist you to overcome that error.