• <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 > 解決1071 Specified key was too long; max key length is 1000 bytes錯(cuò)誤信息

      解決1071 Specified key was too long; max key length is 1000 bytes錯(cuò)誤信息

      時(shí)間:2017-11-13來(lái)源:風(fēng)信官網(wǎng) 點(diǎn)擊: 4219次
      使用Laravel進(jìn)行數(shù)據(jù)庫(kù)遷移文件開發(fā),有些字段我們需要建立索引,

      $table->string('username')->unique();

      當(dāng)創(chuàng)建完索引,并使用

      php artisan migrate:refresh

      重建,發(fā)現(xiàn)提示錯(cuò)誤信息如下:

       [Illuminate\Database\QueryException]
        SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
        QL: alter table `users` add unique `users_username_unique`(`username`))

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

      查看報(bào)錯(cuò)信息我們發(fā)現(xiàn)是由于字段定義的長(zhǎng)度導(dǎo)致,

      修改代碼,對(duì)該索引字段進(jìn)行長(zhǎng)度定義:

      $table->string('username', 60)->unique()->comment('用戶名');

      重新運(yùn)行遷移指令,錯(cuò)誤得到解決,同時(shí)我們也創(chuàng)鍵了索引,截圖如下:
      解決1071 Specified key was too long; max key length is 1000 bytes錯(cuò)誤信息
      熱門關(guān)鍵詞: Laravel php 1071 Specified key max key length 1000 bytes

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

      欄目列表
      推薦內(nèi)容
      熱點(diǎn)內(nè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>