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; max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

// /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 `users` add index `users_userable_type_userable_id_index`(`userable_type`, `userable_id`)

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 (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

Specified key was too long; max key length is 1000 bytes

In appProvidersAppServiceProvider.php File

// Add 
use IlluminateSupportFacadesSchema;

public function boot() {
	// Add In boot function 	
	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

violation: 1071 Specified key was too long; max key length is 1000 bytes

Inside config/database.php, replace this line for mysql

Copy Code
'engine' => null',
with

Copy Code
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
Instead of setting a limit on your string lenght.
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

Specified key was too long; max key length is 767 bytes

I had this error and I changed my tables column length smaller for the indexed foreign key columns so I changed it like this:

VARCHAR(1024)
To:

VARCHAR(512)
And run the query again.
Comment

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

sudo nano /etc/my.cnf.d/server.cnf

[mysqld]
innodb_large_prefix=true
innodb_file_format=barracuda
innodb_file_per_table=true

sudo systemctl restart mariadb
Comment

PREVIOUS NEXT
Code Example
Php :: how to call js function from php 
Php :: laravel module package 
Php :: laravel eloquent get fillable 
Php :: dependable validation in laravel 
Php :: pdo mysqli error handling 
Php :: group_concat mysql limit issue 
Php :: how to save data from api to laravel 
Php :: withsuccess laravel 8 
Php :: how to remove duplicate data in php 
Php :: drupal 9 custom blocks dependency injection 
Php :: php add to array 
Php :: get return value from another function laravel 
Php :: PHP array_merge() Function 
Php :: laravel collection collapse 
Php :: material icons flutter list 
Php :: how to use attempt in laravel 
Php :: how to download file from s3 bucket using php 
Php :: extract text before last space php 
Php :: publish spatie 
Php :: saving an image from pc to php 
Php :: sass download for windows 
Php :: Program for factorial of a number in php 
Php :: convert collection to array laravel 
Php :: laravel pagination with search filter 
Php :: json get/post request in php 
Php :: eloquent insert into select 
Php :: wordpress change slug programmatically 
Php :: match php 
Php :: touches in laravel 
Php :: do_shortcode not working 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =