• About Us
  • Contact Us
  • Privacy Policy
NSR-TECH
No Result
View All Result
  • Login
No Result
View All Result
NSR-TECH
No Result
View All Result
Home Web Development Laravel

Laravel Specified Key Was Too Long Fix

nsr by nsr
January 19, 2021
in Laravel, Web Development
0
Laravel Specified Key Was Too Long Fix

Laravel Specified Key Was Too Long Fix

0
SHARES
27
VIEWS
Share on FacebookShare on Twitter

Laravel Syntax error or access violation: 1071 Specified key was too long error fix

Hi friends, In this article I am going to show you to fix a common error in Laravel. When developing a Laravel or Lumen project most developers will have this specified key was too long error. This issue will occur when you try to migrate your tables to database because older versions of your MariaDB or MySQL. The error will be like as below. Laravel Specified Key Was Too Long Fix

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes.....(and your SQL table details)

So I will show you a quick fix for both Laravel and Lumen.

READ ALSO

Enable CORS on Lumen API

Quasar multiple file upload with laravel API

You have to open a file called AppServiceProvider.php located under app/Providers. Now you have to add these following codes to fix it.

If you haven’t imported schema to the file, First import it after the namespace

use Illuminate\Support\Facades\Schema;

Now you will find a method called boot. Add following line inside the method.

Schema::defaultStringLength(191); 

I will provide an example AppServiceProvider.php will whole code below.

<?php

namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        
    }

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

Thats it! if you have any questions please comment below. Or if you want more articles, go to below link.

Check the latest posts

Tags: developmentlaravelmariadbmysqlphpmyadminweb

Related Posts

Enable CORS on Lumen API
Laravel

Enable CORS on Lumen API

February 6, 2021
Quasar multiple file upload with laravel API
Laravel

Quasar multiple file upload with laravel API

January 21, 2021
MySQL you do not have the super privilege issue fix
Tricks

MySQL you do not have the super privilege issue fix

January 19, 2021
how to seo vue.js site
Quasar

how to SEO vue.js site

January 10, 2021
Vue pagination with Laravel
Vue

Vue pagination with Laravel

October 10, 2020
quasar google maps
Mobile Development

Quasar Google maps with places

October 7, 2020
Next Post
Git branch not showing in Visual Studio Code fix

Git branch not showing in Visual Studio Code fix

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

POPULAR POSTS

quasar-file-upload-img

Quasar file upload process with laravel API

January 21, 2021
lumen framework tutorial

Lumen framework tutorial for beginners

October 24, 2020

Run cordova without android studio

September 12, 2020
quasar google maps

Quasar Google maps with places

October 7, 2020
MySQL you do not have the super privilege issue fix

MySQL you do not have the super privilege issue fix

January 19, 2021

EDITOR'S PICK

How to save media on iPhone storage

How to save media on iPhone storage

October 14, 2020
Quasar multiple file upload with laravel API

Quasar multiple file upload with laravel API

January 21, 2021
Domain name system

Domain name system

December 4, 2020
how to seo vue.js site

how to SEO vue.js site

January 10, 2021

About

Nsrtech is a blog which brings you high quality and valuable articles to your life. All articles will be on different categories which all peoples can solve their issues in a single blog site.

Follow us

Categories

  • Laravel
  • Mobile Development
  • Networking Lessons
  • Others
  • Quasar
  • Quasar
  • Software Guides
  • Theories
  • Tricks
  • Vue
  • Web Development
  • Web Development Lessons

Recent Posts

  • Upgrade PHP from 7.2 to 7.3 on Ubuntu OS
  • Enable CORS on Lumen API
  • Quasar multiple file upload with laravel API
  • Git branch not showing in Visual Studio Code fix
  • Home
  • About Us
  • Contact Us
  • Privacy Policy

© 2020 NSR-TECH Blog .

No Result
View All Result
  • Homepages
    • Home Page 1
    • Home Page 2

© 2020 NSR-TECH Blog .

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In