laravel 运行migrate报错 1071 Specified key was too long
laravel运行命令migrate时报错:
1071 Specified key was too long; max key length is 1000 bytes (S
QL: 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 1000 bytes
解决:
升级MySql版本到5.5.3以上。
手动配置迁移命令
migrate生成的默认字符串长度,App/Providers/AppServiceProvider.php<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
}
记录点滴,迭代精进,追求新生。Email: 942298768@qq.com

浙公网安备 33010602011771号