I use Lumen 5.6 and mysql. when i type "php artisan migrate" following error occur:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t
oo long; max key length is 767 bytes (SQL: alter table `users` add unique `
users_email_unique`(`email`))
I put following code into "boot" method in the AppServiceProvider
Schema::defaultStringLength(191);
but I didn't achieve to any success.
you just need one more step
go to app.php on bootstrap folder and uncomomment or modif this line
to this code
have a good day
AppServiceProvider
class:You need couple of things to do. I also faced this issue and fixed it by following these two steps
Go to app.php in bootstrap directory and uncomment or modify this line.
Now you need to define
boot()
function inAppServiceProvider
fileThen you are good to go!
Go to config in file
database.php
then editto
Known to work in Laravel/Lumen 7.x:
I've tried the un-commenting of
AppServiceProvider::class
and other solutions mentioned above, but the following worked for me.If you look in
/vendor/laravel/lumen-framework/config/database.php
forcharset
andcollation
, the code checks your.env
file and resorts toutf8mb4
andutf8mb4_unicode_ci
, respectively.If your database' charset is set to
utf8
and collation toutf8_unicode_ci
, simply add the following to your.env
file: