Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illuminate\Database\QueryException ( Specified key was too long ) #44

Open
mahdirashidi opened this issue Jan 31, 2021 · 2 comments
Open

Comments

@mahdirashidi
Copy link

php artisan world:init
Execute migrate first, migrating...
Migrating: 2017_04_08_163453_create_world_cities_locale_table
Migrated: 2017_04_08_163453_create_world_cities_locale_table (80.40ms)
Migrating: 2017_04_08_163453_create_world_cities_table

Illuminate\Database\QueryException

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))

at vendor\laravel\framework\src\Illuminate\Database\Connection.php:678
674▕ // If an exception occurs when attempting to run a query, we'll format the error
675▕ // message to include the bindings with SQL, which will make this exception a
676▕ // lot more helpful to the developer instead of just the database's errors.
677▕ catch (Exception $e) {
➜ 678▕ throw new QueryException(
679▕ $query, $this->prepareBindings($bindings), $e
680▕ );
681▕ }
682▕

  1. vendor\laravel\framework\src\Illuminate\Database\Connection.php:471
    PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")

  2. vendor\laravel\framework\src\Illuminate\Database\Connection.php:471
    PDOStatement::execute()

@gausoft
Copy link

gausoft commented Jan 31, 2021

Hi, if you have created your database with utf8 general_ci collation, try this params :

'charset' => 'utf8',
'collation' => 'utf8_general_ci',

in config/database.php

@gausoft
Copy link

gausoft commented Feb 1, 2021

If not solved, try this solution https://blog.neversyn.com/how-to-fix-specified-key-was-too-long-issue/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants