• <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
  • <th id="l3qpx"><progress id="l3qpx"></progress></th>
      <th id="l3qpx"></th>
      <dd id="l3qpx"><font id="l3qpx"></font></dd>
      <th id="l3qpx"></th>
      0712-2888027 189-8648-0214
      微信公眾號(hào)

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

      當(dāng)前位置:主頁(yè) > 技術(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來(lái)源:風(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ù)庫(kù)存儲(chǔ)「表情」。如果你正在運(yùn)行的 MySQL release 版本低于5.7.7 或 MariaDB release 版本低于10.2.2 ,為了MySQL為它們創(chuàng)建索引,你可能需要手動(dòng)配置遷移生成的默認(rèn)字符串長(zhǎng)度,你可以通過(guò)調(diào)用 AppServiceProvider 中的 Schema::defaultStringLength 方法來(lái)配置它:

      use Illuminate\Support\Facades\Schema;

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

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

      修改文件:\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ù)庫(kù)

      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
      熱門(mén)關(guān)鍵詞: Laravel migrate 命令報(bào)錯(cuò) Specified key

      您可能感興趣的相關(guān)文章:

      欄目列表
      推薦內(nèi)容
      熱點(diǎn)內(nèi)容
      展開(kāi)
      欧美一区二区三区免费A级视频,亚洲精品中文字幕综合,动漫精品中文字幕无码第一页,1024亚洲国产综合 亚太影院 柯西贝尔-游戏赚网
    1. <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
    2. <th id="l3qpx"><progress id="l3qpx"></progress></th>
        <th id="l3qpx"></th>
        <dd id="l3qpx"><font id="l3qpx"></font></dd>
        <th id="l3qpx"></th>