美文网首页
laravel 错误

laravel 错误

作者: HaRun | 来源:发表于2017-09-25 22:21 被阅读0次
    [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`))     
    

    修复方法:

    在App\Providers\AppServiceProvider.php文件中boot()添加:

    <?php
    namespace App\Providers;
    
    use Illuminate\Support\Facades\Schema;//记得添加这个类哦
    use Illuminate\Support\ServiceProvider;
    
    class AppServiceProvider extends ServiceProvider
    {
        /**
         * Bootstrap any application services.
         *
         * @return void
         */
        public function boot()
        {
            Schema::defaultStringLength(191);//添加此代码
        }
    
        /**
         * Register any application services.
         *
         * @return void
         */
        public function register()
        {
            //
        }
    }
    

    相关文章

      网友评论

          本文标题:laravel 错误

          本文链接:https://www.haomeiwen.com/subject/kbcjextx.html