Skip to content

Instantly share code, notes, and snippets.

@afsardo
Last active June 30, 2017 01:23
Show Gist options
  • Save afsardo/29224059b85eb50700727c0de9d56cd2 to your computer and use it in GitHub Desktop.
Save afsardo/29224059b85eb50700727c0de9d56cd2 to your computer and use it in GitHub Desktop.
Laravel 5.4: Specified key was too long error
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

Laravel 5.4: Specified key was too long error

Laravel 5.4 made a change to the default database character set, and it’s now utf8mb4 which includes support for storing emojis.

This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything.

For those running MariaDB or older versions of MySQL you may hit this error when trying to run migrations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment