mysql数据库插入数据错误Error Code: 1118 - Row size too large (> 8126)

转载自:http://www.log4cpp.com/learnother/27.htmlhtml

 

今天在本地调试的时候,把从服务器上导出的sql文件导入到本地的mysql上,可是在执行的过程当中却收到了这个错误mysql

”Error Code: 1118 - 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.“sql

按照提示说要使用ROW_FORMAT=DYNAMIC这个表示,我查看表信息的确有这个标识,表示很不理解。windows

通过一番探索原来是这么回事,有以下2种解决办法服务器

 

一、使用MyIsam引擎

把表的引擎修改成MyIsam,从新执行插入的sql语句成功。spa

 

二、修改My.cnf配置文件

首先确认是不是使用Innodb引擎,若是不是那就参考第一种办法,innodb中能够经过innodb_file_format设置为Barracuda,Barracuda中支持 ROW_FORMAT=COMPRESSED调试

对于mysql版本 5.1 表类型orm

innodb中默认的格式是row_format=compact   innodb_file_format选项不存在, 也就无从谈起Barracuda格式。 设置row_format=dynamic也是没意义的,因此只能改存储引擎。htm

对于mysql版本 5.5 表类型get

innodb默认格式是row_format=compact ,插入大于8126的数据会报错: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. 

能够经过修改my.cnf文件,指定row_format=Barracuda

找到my.cnf文件(windows下是my.ini,若是没有把my-default.ini拷贝一份重命名成my.ini),在[mysqld]后边增长两行

innodb_file_per_table = 1

innodb_file_format = Barracuda

而后重启mysql服务,并从新建立表

 

三、使用set global 命令动态的修改

使用以下命令修改

SET GLOBAL innodb_file_format=barracuda;

SET GLOBAL innodb_file_per_table=1;

 

注意:

1) 修改后的innodb_file_format格式, 只影响后续建立的表。 也就是后续建立的表,能够支持把row_format设为dynamic,以前建立的表仍然会报错

2) SET GLOBAL 只是在mysql服务器运行期间有效,重启后innodb_file_format还原为原来的格式。

3) 判断一个表是否支持超过10个blob的字段的简单办法: show table status like 't1' \G 查看 Row_format , 若是是Compact, 一定不支持, 若是是dynamic, 则支持。

相关文章
相关标签/搜索