幸福

如人饮水,冷暖自知

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long

laravel5.5在使用命令php artisan migrate生成表的过程中报错如下:

[Illuminate\Database\QueryException] SQLSTATE[42000]: 
Syntax error or access violation: 1071 Specified key was too long; 
max key length is 767 bytes
 (SQL: alter table `users` add unique `users_email_unique`(`email`)) [PDOException] 
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; 
max key length is 767 bytes

解决方法:

/project/app/Providers/AppServiceProvider.php 中boot()方法修改如下:

public function boot()  {

Schema::defaultStringLength(191); //Solved by increasing StringLength

}



去打赏

您的支持将鼓励我们继续创作!

[微信] 扫描二维码打赏

[支付宝] 扫描二维码打赏

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注