MySQL插入单行数据较大时报Row size too large错误 解决方案

Posted 又见江南

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL插入单行数据较大时报Row size too large错误 解决方案相关的知识,希望对你有一定的参考价值。

mysql 版本 5.5

向目的MySQL写入数据时,单行数据较大,遇到插入失败,报错信息如下:
Error ‘Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.‘ on query. ......

 

 

解决:

1. 先查看

show GLOBAL VARIABLES LIKE ‘%file_format%‘;  
+--------------------------+----------+
| Variable_name            | Value    |
+--------------------------+----------+
| innodb_file_format       | Antelope |
| innodb_file_format_check | ON       |
| innodb_file_format_max   | Antelope |
+--------------------------+----------+

mysql> show variables like ‘%per_table%‘;
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | OFF   |
+-----------------------+-------+
1 row in set (0.03 sec)


2. 修改参数: my.cf中在[mysqld] 加入

innodb_file_format = Barracuda
innodb_file_per_table = 1 

    检查修改后的结果:

mysql> show variables like ‘%per_table%‘;
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
1 row in set (0.00 sec)


mysql> show GLOBAL VARIABLES LIKE ‘%file_format%‘;
+--------------------------+-----------+
| Variable_name            | Value     |
+--------------------------+-----------+
| innodb_file_format       | Barracuda |
| innodb_file_format_check | ON        |
| innodb_file_format_max   | Barracuda |
+--------------------------+-----------+
3 rows in set (0.00 sec)

3. 修改表

Alter table <table_name> engine=innodb ROW_FORMAT=DYNAMIC;


以上是关于MySQL插入单行数据较大时报Row size too large错误 解决方案的主要内容,如果未能解决你的问题,请参考以下文章

在用mybatis向MySQL数据库中插入时间时报错:Incorrect datetime value: '' for column '' at row 1

MySQL - Row size too large (> 8126). Changing some columns to TEXT or BLOB

MySQL - Row size too large (> 8126). Changing some columns to TEXT or BLOB

mysql插入数据 报错[Err] 1136 - Column count doesn't match value count at row 1(表中有自增列)

MySql数据库执行insert时候报错:Column count doesn't match value count at row 1

mySql插入数据,关于Cannot add or update a child row: a foreign key constraint fails的问题,