聯系官方銷售客服
1835022288
028-61286886
MySQL數據庫index column size too large. the maximum column size is 767 bytes問題解決方法:
最快捷的方法是切換數據庫版本,MySQL57 MySQL8+分別切換試一試,如果不想切換數據庫版本就往下看(也可以百度搜索設置方法)
在恢復一個mysql庫的備份文件時遇到報錯,報錯信息為index column size too large. the maximum column size is 767 bytes,此問題為備份的庫索引過長超過限制,目標數據庫引擎為INNODB 引擎,編碼UTF-8,主鍵字符串默認最大767,理論上是需要優化備份數據庫的,但是在實際環境中如果沒辦法優化,我們可以通過配置目標數據庫來解決這個報錯
mysql在執行腳本時,報出了以下錯誤:
index column size too large. the maximum column size is 767 bytes
原因:
INNODB 引擎,UTF-8,主鍵字符串 默認最大 767,需要修改
解決方案:
1. 對數據庫進行設置
set global innodb_file_format = BARRACUDA
set global innodb_large_prefix = ON
注意: 在navicat中執行成功,不清楚重啟數據庫是否還有效
查看是否生效
show variables like 'character%';
show variables like 'collation_%';
show variables like 'innodb_large_prefix';
show variables like 'innodb_file_format';
============================================
修改數據庫的配置文件(vim /etc/my.cnf),加入如下兩行配置
innodb_large_prefix=on innodb_file_format=BARRACUDA
重啟數據庫并登錄數據庫檢查配置是否生效
service mysql restart show variables like 'innodb_large_prefix'; show variables like 'innodb_file_format';