laravel-world
laravel-world copied to clipboard
SQLSTATE[42000]: Syntax error or access violation: 1071
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
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
}