Search
 
SCRIPT & CODE EXAMPLE
 

PHP

PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes") laravel 8

// Update your /app/Providers/AppServiceProvider.php to contain:

use IlluminateSupportFacadesSchema;

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

//ON this error 
//   PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists")
// After run ->  php artisan migrate:fresh  <- ! Note this will reset all tables in db
Comment

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

// /app/Providers/AppserviceProvider.php

use IlluminateSupportFacadesSchema;

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

Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table

Path : App/Providers/AppServiceProvider

Schema::defaultStringLength(191);
in AppServiceProvider didn't work for me. What worked for was editing the database.php file in config folder. Just edit

'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
to

'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
and it should work, although you will be unable to store extended multibyte characters like emoji.
Comment

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

// Para resolver isso siga os passos abaixo:

// Edite o arquivo appProvidersAppServiceProvider.php
// Adicione o namespace use IlluminateSupportFacadesSchema;
// Dentro do método boot adicione Schema::defaultStringLength(191);
// Resultado final do arquivo:

use IlluminateSupportFacadesSchema;

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

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

use IlluminateSupportFacadesSchema;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191);
}
Comment

ERROR 1071 (42000) at line 76: Specified key was too long; max key length is 767 bytes laravel

'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
Comment

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


According to the official Laravel 7.x documentation, you can solve this quite easily.

Update your /app/Providers/AppServiceProvider.php to contain:

use IlluminateSupportFacadesSchema;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191);
Comment

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

// Solution 1
// In App/Providers/AppServiceProvider.php

use IlluminateSupportFacadesSchema;

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


// Solution 2
// In config/database.php
// For 'mysql' change

'mysql' => [
			// 'engine' => null,
            'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
        ],
Comment

ERROR 1071 (42000) at line 76: Specified key was too long; max key length is 767 bytes laravel

'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
Comment

PREVIOUS NEXT
Code Example
Php :: datetime validation in laravel 
Php :: <a href="<?php echo base_url(); ?"somelink</a 
Php :: define constant in php 
Php :: laravel check if object is empty 
Php :: laravel 6 get user id 
Php :: laravel redirect url 
Php :: Add Empty Cart Button WooCommerce 
Php :: unlink is a directory laravel 
Php :: sum of the array elements in php 
Php :: custom 404 page in laravel 
Php :: How to remove updated_at or use only created_at laravel eloquent ORM 
Php :: Type cast using double php 
Php :: string to array in php 
Php :: join multiple tables in laravel eloquent 
Php :: php check if string contains words from array 
Php :: How to write a loop in PHP 
Php :: get post php 
Php :: call model function in controller laravel 
Php :: php shell_exec with root 
Php :: php convert to boolean 
Php :: Generating Random String In PHP Using uniqid() function 
Php :: check the ajax request in laravel 
Php :: php compare two arrays of objects 
Php :: laravel post request search query 
Php :: varchar max length define laravel migration 
Php :: php regex match numbers only 
Php :: laravel query with trashed 
Php :: htmlspecialchars (PHP 4, PHP 5, PHP 7, PHP 8) htmlspecialchars — Convert special characters to HTML entities 
Php :: phpoffice spreadsheet background color 
Php :: laravel order by numbers 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =