Skip to main content

Solution to 1071:Specified key was too long problem in Laravel.

Published 1 min readMarkdown
Solution to 1071:Specified key was too long problem in Laravel.

Hi there, If you encountered this error message on laravel

[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long;

Then here's a quick fix, All you have to do is to add the following code in the

app\Providers\AppServiceProvider.php.

use Illuminate\Support\Facades\Schema;

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

Now run a fresh migration with

php artisan migrate:fresh

This will solve the problem.

Happy Coding.

39 views

About the author

  • I am CS Student currently perusing my bachelor degree. I love coding and implementing new logics. Aside from that I'm also a hardware lover and has great interest in IOT.

No comments yet. Be the first to comment.

More from this blog