Syntax error or access violation: 1071 specified key was too long on Laravel 5.4 and 5.5 Migration [Solved]
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
First, go to App>>Providers and open AppServiceProvider. Inside boot function, copy and paste the following code.
Note: Don’t forget to include
use Illuminate\Support\Facades\Schema; above the class AppServiceProvider
Now your code will be like this.
class AppServiceProvider extends ServiceProvider
* Bootstrap any application services.
* @return void
public function boot()
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.