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=on innodb_file_format=BARRACUDA12
重启数据库并登录数据库检查配置是否生效
service mysql restart show variables like 'innodb_large_prefix'; show variables like 'innodb_file_format';
上一篇:提交内容时报503/403错误
下一篇:如何排查js错误
有站啦CMS®万能建站系统基于 CodeIgniter4 高性能的开发框架,支持接入Laravel、ThinkPHP三种内核可选,基于MIT开源许可协议,免费且不限制商业使用。 提供PC + 手机 + 微信 + 小程序 + APP API + 多终端一体化网站技术解决方案。