21/8/2017 Laravel 5.
4: Specified key was too long error - Laravel News
virtualizat
Windows Server 2016 guide. Rea
L A R AV E L 5 .4 / JA N UA RY 25, 2 0 1 7
Laravel 5.4: Speci ed key was too long
error
Laravel 5.4 made a change to the default database character set, and its now
utf8mb4 which includes support for storing emojis. This only a ects 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:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long;
https://laravel-news.com/laravel-5-4-key-too-long-error 1/4
21/8/2017 Laravel 5.4: Specified key was too long error - Laravel News
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
As outlined in the Migrations guide to fix this all you have to do is edit your
AppServiceProvider.php file and inside the boot method set a default string
length:
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
A er that everything should work as normal.
SHARE
Laravel News
by Eric L. Barnes
MariaDB MySQL
L A R AV E L N E W S PA RT N E R S
https://laravel-news.com/laravel-5-4-key-too-long-error 2/4
21/8/2017 Laravel 5.4: Specified key was too long error - Laravel News
SPONSOR / BECOME A SPONSOR
Cindicator ICO 09/2017
Millions of decentralized
nancial analysts enhanced
by AI. Pre-Order. Sign Up.
Newsletter
Join the weekly newsletter and never miss out on new tips, tutorials, and more.
EMAIL ADDRESS SUBSCRIBE
Laravel Jobs
Are you the "leader of the pack" seeking disruption and rewards?...
Laravel So ware Developer
View more Jobs Post a Job
https://laravel-news.com/laravel-5-4-key-too-long-error 3/4
21/8/2017 Laravel 5.4: Specified key was too long error - Laravel News
PhpStorm EAP adds support for Blade Components and
Slots
JetBrains has just released PhpStorm 2017.1 EAP build (171.2613)
and through the Laravel plugin, it now supports the
Laravel 5.4 Is Now Released
Version 5.4 of Laravel is now o icially released! This release has many
new features, and improvements and here is q
LINKS NEWSLETTER ADVERTISE ARCHIVE JOBS YOUR ACCOUNT
C O N TA C T
NEWS TUTORIALS PACK AGES BOOKS INTERVIEWS A P P L I C AT I O N S
2 0 1 2 - 2 0 17 L A R AV E L N E W S BY E R IC L . B A R N E S - A DI V IS IO N O F D OT D E V I N C .
D E S I G N & F R O N T- E N D C O D E B Y
https://laravel-news.com/laravel-5-4-key-too-long-error 4/4