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