MySQL 建索引時 Specified key was too long; max key length is 767 bytes 錯誤的處理


MySQL 建索引時 Specified key was too long; max key length is 767 bytes 錯誤的處理

版權聲明:本文為博主原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。
本文鏈接: https://blog.csdn.net/a1173537204/article/details/88039245

先檢查一下是不是數據庫被限制了索引的大小
SHOW variables like 'innodb_large_prefix'

如果查詢的值是OFF的話 執行下面命令

SET GLOBAL INNODB_LARGE_PREFIX = ON;
 

執行完了 之后 還得查看當前的innodb_file_format引擎格式類型是不是BARRACUDA

執行

SHOW variables like 'innodb_file_format'

如果不是的話則需要修改

SET GLOBAL innodb_file_format = BARRACUDA;

 

 創建表的時候指定表的 row format 格式為 Dynamic 或者 Compressed,如下示例:

  1.  
    create table idx_length_test_02
  2.  
    (
  3.  
    id int auto_increment primary key,
  4.  
    name varchar(255)
  5.  
    )
  6.  
    ROW_FORMAT=DYNAMIC default charset utf8mb4;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM