How to Fix Specified Key Was Too Long Error - Laravel 5.4

Laravel 5.4 made a change to the default database character set, which will cause issues for anyone that is trying to run their new project using Older versions of MySQL (5.7.7 and below) or MariaDB.

It’s default charset is now utf8mb4 which includes support for storing emojis.

Recently I have tried migrating a project across from local development server to a production server running PHP 5.6 and MySQL 5.6 which are classed as STABLE RELEASE.

On trying to import the DB into phpmyadmin it crashes with the following error:

Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

However there is a migration fix which is listed within the documentation here (towards the bottom of the page)

Just open your project and find the AppServiceProvider.php inside appproviders directory.

And add the following line within the boot function:

However as practice we now add this line by default within our projects as most production servers are running the STABLE releases by default.

Copyright 2007 - 2024 southcoastweb is a brand of DSM Design.