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

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

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

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

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 :: get hours difference between two dates in php 
Php :: laravel eloquent increment 
Php :: for install perticular version in vue with laravel 
Php :: PHPspreadsheet getColumnDimension 
Php :: php get myme type of image 
Php :: change laravel mix to run on different port 
Php :: Date time format for laravel validation 
Php :: php array has value 
Php :: header location php 
Php :: laravel not finding asset files in public directory 
Php :: how to get the link of the current page in php 
Php :: laravel get last 5 records 
Php :: get logged in user name yii2 
Php :: laravel check method is post 
Php :: for loop php continue to next item 
Php :: laravel http request plain text 
Php :: show php info 
Php :: file original extensions laravel 
Php :: is php still used 
Php :: add to url anchor tag laravel with variable 
Php :: php random float number with 2 decimal places 
Php :: php format date 
Php :: header.php file how to fetch in index.php file in wordpress 
Php :: laravel download file 
Php :: symfony call another controller 
Php :: php change an associative array into indexed array 
Php :: php artian migrate table 
Php :: Morocco 
Php :: php header excel utf-8 
Php :: pasar variables con cronjob 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =