Windows Server 2016: Laravel 5.4: Speci Ed Key Was Too Long Error
Windows Server 2016: Laravel 5.4: Speci Ed Key Was Too Long Error
virtualizat
Windows Server 2016 guide. Rea
L A R AV E L 5 .4 / JA N UA RY 25, 2 0 1 7
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;
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
Newsletter
Join the weekly newsletter and never miss out on new tips, tutorials, and more.
Laravel Jobs
Are you the "leader of the pack" seeking disruption and rewards?...
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
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