CMS数据库提示 index column size too large


MySQL数据库index column size too large. the maximum column size is 767 bytes问题解决


在恢复一个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=oninnodb_file_format=BARRACUDA12

重启数据库并登录数据库检查配置是否生效

service mysql restartshow variables like 'innodb_large_prefix';show variables like 'innodb_file_format';


发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章