日韩亚洲AV无码一区二区三区|av在线国产哟哟|国产精品人人爽人人爽AV|免费一区二区精品无码视频

<th id="kwciy"><video id="kwciy"></video></th>
<code id="kwciy"><em id="kwciy"><optgroup id="kwciy"></optgroup></em></code>
    1. <center id="kwciy"></center>

      <code id="kwciy"></code>

      0712-2888027 189-8648-0214
      微信公眾號(hào)

      孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號(hào)

      當(dāng)前位置:主頁 > 技術(shù)支持 > PHP > Laravel 5.4運(yùn)行migrate命令報(bào)錯(cuò)1071 Specified key was too long解決方案

      Laravel 5.4運(yùn)行migrate命令報(bào)錯(cuò)1071 Specified key was too long解決方案

      時(shí)間:2017-06-19來源:風(fēng)信官網(wǎng) 點(diǎn)擊: 1785次
      Laravel 5.4運(yùn)行migrate命令報(bào)錯(cuò)1071 Specified key was too long解決方案如下:

      D:\Laravel5.4>php artisan migrate
      Migration table created successfully.


        [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`))

        [PDOException]
        SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes

      Laravel 默認(rèn)使用 utf8mb4 字符,包括支持在數(shù)據(jù)庫存儲(chǔ)「表情」。如果你正在運(yùn)行的 MySQL release 版本低于5.7.7 或 MariaDB release 版本低于10.2.2 ,為了MySQL為它們創(chuàng)建索引,你可能需要手動(dòng)配置遷移生成的默認(rèn)字符串長(zhǎng)度,你可以通過調(diào)用 AppServiceProvider 中的 Schema::defaultStringLength 方法來配置它:

      use Illuminate\Support\Facades\Schema;

      /**
       * 引導(dǎo)任何應(yīng)用程序服務(wù)。
       *
       * @return void
       */
      public function boot()
      {
          Schema::defaultStringLength(191);
      }

      或者你可以為數(shù)據(jù)庫開啟 innodb_large_prefix 選項(xiàng),有關(guān)如何正確開啟此選項(xiàng)的說明請(qǐng)查閱數(shù)據(jù)庫文檔。

      修改文件:\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);
          }
      
          /**
           * Register any application services.
           *
           * @return void
           */
          public function register()
          {
              //
          }
      }
      

      重新運(yùn)行php artisan migrate命令創(chuàng)建數(shù)據(jù)庫

      D:\phpStudy\Laravel5.4>php artisan migrate
      Migration table created successfully.
      Migrating: 2014_10_12_000000_create_users_table
      Migrated:  2014_10_12_000000_create_users_table
      Migrating: 2014_10_12_100000_create_password_resets_table
      Migrated:  2014_10_12_100000_create_password_resets_table
      欄目列表
      推薦內(nèi)容
      熱點(diǎn)內(nèi)容
      展開