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