Larabel迁移文件发生错误怎么办?

Larabel迁移文件发生错误怎么办?,第1张

Larabel迁移文件发生错误怎么办? 下面由Laravel教程栏目带大家介绍关于Larabel迁移文件时报SQLSTATE[42000]错误的解决方法,希望对大家有所帮助!

Laravel执行php artisan migrate命令时,报如错误的解决方法
Illuminate\Database\QueryException  : 
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; 
max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
解决方法修改 app/Providers/AppServiceProvider.php文件中添加如下内容:
<?php

namespace App\Providers;use Illuminate\Support\ServiceProvider;use Illuminate\Support\Facades\Schema;class AppServiceProvider extends ServiceProvider{
    public function register()
    {
    }

    public function boot()
    {
        Schema::defaultStringLength(191);
    }}
修改部分
Schema::defaultStringLength(191);
相关推荐:最新的五个Laravel视频教程

以上就是Larabel迁移文件发生错误怎么办?的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/701118.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-23
下一篇 2022-04-23

发表评论

登录后才能评论

评论列表(0条)

保存