我安装了laravel 5.5并且当我运行 php artisan migrate
时告诉我这个错误
[Illuminate \ Database \ QueryException] SQLSTATE [42000]:语法错误或访问冲突:1071指定密钥太长;最大密钥长度为767字节(SQ L:alter table users添加唯一users_email_unique(email))
我在 AppServiceProvider.php
上添加以下代码
public function boot()
{
Schema::defaultStringLength(191); //Solved by increasing StringLength
}
然后告诉我这个错误
[Illuminate \ Database \ QueryException] SQLSTATE [42000]:语法错误或访问冲突:1067“created_at”的默认值无效(SQL:create table password_resets(email varchar(191)not null,token varchar(191)not null, created_at timestamp not null)de fault character set utf8mb4 collate utf8mb4_unicode_ci)
1 回答
您可以使用
nullableTimestamps()
而不是timestamps()
要么
请查看以下参考链接:
https://github.com/laravel/framework/issues/3602
https://laracasts.com/discuss/channels/forge/syntax-error-or-access-violation-1067-invalid-default-value-for-created-at