mysql [Err] 1118 - Row size too large (> 8126).

错误代码: 1118 
Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.

问题

mysql5.7 在执行创建表或者增加字段时,发现row size长度过长,导致出现以下错误。

[Err] 1118 - Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.

解决方案

row size 其实就是所有字段的长度的总和。在不进行拆表的前提下解决(我们不讨论是否设计的合理性): 知识贴: https://dev.mysql.com/doc/refman/8.0/en/column-count-limit.html

You may want to take a look at this article which explains a lot about MySQL row sizes. It's important to note that even if you use TEXT or BLOB fields, your row size could still be over 8K (limit for InnoDB) because it stores the first 768 bytes for each field inline in the page.

The simplest way to fix this is to use the Barracuda file format with InnoDB. This basically gets rid of the problem altogether by only storing the 20 byte pointer to the text data instead of storing the first 768 bytes.

方法一:改变一些字段varchar为TEXT or BLOB。 无效,不能解决问题。

最终解决方案

https://stackoverflow.com/questions/22637733/mysql-error-code-1118-row-size-too-large-8126-changing-some-columns-to-te

查询系统参数:

show variables like '%innodb_strict_mode%';  

show variables like '%innodb_log_file_size%';

修改前:

innodb_strict_mode	ON
innodb_log_file_size	536870912

修改mysql的配置文件, vi /etc/my.cnf

innodb_log_file_size=1024M
innodb_strict_mode=0

innodb_strict_mode=0 这个一定不能漏,否则不能生效。 重启后:

innodb_strict_mode	OFF
innodb_log_file_size	1073741824

it work 。 卡了很久,最终靠这个方案解决了。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
[ERR] 1118 - Row size too large (> 8126) 是MySQL数据库中的一个错误,它表示行的大小超过了MySQL所允许的最大大小。这个错误通常发生在创建或修改表时,当表中的列太多或者列的数据类型太大时会出现。 解决这个问题的方法有以下几种: 1. 调整列的数据类型:将一些列的数据类型从较大的数据类型(如VARCHAR)改为较小的数据类型(如TEXT或BLOB)。这样可以减小行的大小,从而解决该错误。但需要注意的是,改变列的数据类型可能会影响到应用程序的逻辑和性能,所以在进行修改之前需要仔细考虑。 2. 使用压缩技术:MySQL提供了一些压缩技术,如InnoDB引擎的行压缩和页压缩。通过使用这些压缩技术,可以减小行的大小,从而解决该错误。但需要注意的是,压缩技术可能会对查询性能产生一定的影响。 3. 拆分表:如果表中的列过多,并且无法通过调整数据类型或使用压缩技术解决该错误,可以考虑将表拆分成多个表。将一些列移动到新的表中,然后通过外键关联这些表。这样可以减小每个表的行大小,从而解决该错误。 4. 使用分区表:MySQL提供了分区表的功能,可以将一个大表分成多个小的分区。每个分区可以单独管理和查询,从而减小每个分区的行大小,从而解决该错误。 总之,解决[ERR] 1118 - Row size too large (> 8126) 错误的方法主要是通过调整列的数据类型、使用压缩技术、拆分表或使用分区表来减小行的大小。具体的解决方法需要根据具体的情况来确定。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值