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

SQLSTATE[42000]: 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`))

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

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: a lter table `users` add unique `users_email_unique`(`email`))

// Go to your AppServiceProvider.php and update the boot() method with:

use IlluminateSupportFacadesSchema;
/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191); 
}
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

PREVIOUS NEXT
Code Example
Php :: if field is filled out acf 
Php :: eloquent where between 
Php :: Call to undefined function AppModelsstr_slug() 
Php :: laravel logout 
Php :: ubuntu install php mongodb extension 
Php :: how to remove notice error in php 
Php :: php header pdf open in browser 
Php :: php make query string from array http_build_query 
Php :: get information from another website 
Php :: php xml to array 
Php :: laravel blade for loop 
Php :: php post self 
Php :: laravel make directory if not exists 
Php :: wpml get translated post id 
Php :: get thumbnail alt wordpress 
Php :: php directory exists 
Php :: laravel ide helper 
Php :: string contains php 
Php :: get name of parent dir php 
Php :: get key of last element php 
Php :: php ellipsis 
Php :: laravel db seed specific class 
Php :: laravel dateinterval not found 
Php :: lravel redirect with error 
Php :: phpstorm serial key 2020.2.3 
Php :: php echo html response code 200 
Php :: php date + 1 year 
Php :: insert php mysql 
Php :: parent directory in php 
Php :: how to set field type of date of birth in laravel 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =