khsing / laravel-world

provide countries, states, and cities relations and database.
MIT License
427 stars 89 forks source link

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

Open glupeksha opened 4 years ago

glupeksha commented 4 years ago

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

yehanny commented 4 years ago

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
    }