Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `u sers_email_unique`(`email`))

Got error message while running “php artisan migrate” at laravel 5.7

Solution

For laravel 5.7
This solution solve my problem
go to config/database.php
Find the code below

‘mysql’ => [
‘driver’ => ‘mysql’,
‘host’ => env(‘DB_HOST’, ‘127.0.0.1’),
‘port’ => env(‘DB_PORT’, ‘3306’),
‘database’ => env(‘DB_DATABASE’, ‘forge’),
‘username’ => env(‘DB_USERNAME’, ‘forge’),
‘password’ => env(‘DB_PASSWORD’, ”),
‘unix_socket’ => env(‘DB_SOCKET’, ”),
‘charset’ => ‘utf8mb4’,
‘collation’ => ‘utf8mb4_unicode_ci’,
‘prefix’ => ”,
‘strict’ => true,
‘engine’ => null,
],
Change this two field

‘charset’ => ‘utf8mb4’,
‘collation’ => ‘utf8mb4_unicode_ci’

With This

‘charset’ => ‘utf8’,
‘collation’ => ‘utf8_unicode_ci’

Cheers

Advertisements