laravel-world icon indicating copy to clipboard operation
laravel-world copied to clipboard

SQLSTATE[42000]: Syntax error or access violation: 1071

Open glupeksha opened this issue 4 years ago • 1 comments

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table world_cities add index uniq_city(country_id, division_id, name))

This error occurred when php artisan world:init command is executed

glupeksha avatar Mar 23 '20 12:03 glupeksha

Hi @upeksha1996 you can try this solution it worked for me:

Option 1: Add the following to your my.ini Config file, I did it on XAMPP Control Panel > Config > my.ini and look for the InnoDB options and place this code below, restart MySQL and Apache and it should work.

innodb-file-format=barracuda
innodb-file-per-table=ON
innodb-large-prefix=ON
innodb_default_row_format = 'DYNAMIC'

Option 2

Also you can try to update your app/Providers/AppServiceProvider.php

use Illuminate\Support\Facades\Schema; // Import Schema where defaultStringLength method is defined

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

yehanny avatar May 04 '20 17:05 yehanny