本文介绍了流明5.6迁移错误指定的密钥太长,最大密钥长度为767字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Lumen 5.6和mysql.当我输入"php artisan migration"时,会发生以下错误:
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`))
我将以下代码放入AppServiceProvider中的启动"方法中
I put following code into "boot" method in the AppServiceProvider
Schema::defaultStringLength(191);
但是我没有取得任何成功.
but I didn't achieve to any success.
推荐答案
您只需要再做一步
转到bootstrap文件夹中的app.php并取消注释或修改此行
go to app.php on bootstrap folder and uncomomment or modif this line
// $app->register(App\Providers\AppServiceProvider::class);
此代码
$app->register(App\Providers\AppServiceProvider::class);
祝你有美好的一天
这篇关于流明5.6迁移错误指定的密钥太长,最大密钥长度为767字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!