Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

HUGE_DICK_10_INCHES's avatar

Laravel sqlstate 42000 even in v5.7

Why am I getting this problem on every version I use (5.6 & 5.7)

Try to migrate and get:

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

Then I need to go to AppServiceProvider and add:

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

Is this only happening to me or will it ever get fixed?

Its happening on 3 different machines (2 laptops [win7 & win10] & pc [win10]) on mysql installed via xampp and even on hosting.

This does fix it but it is annoying to do same thing all over again :D

Update:

> mysql -v
> Server version: 10.1.31 -MariaDB
0 likes
1 reply
Cronix's avatar
Cronix
Best Answer
Level 67

Update MariaDB > 10.2

Please or to participate in this conversation.