• mysql数据库插入数据错误Error Code: 1118


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

    今天在本地调试的时候,把从服务器上导出的sql文件导入到本地的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.“

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

    经过一番探索原来是这么回事,有如下2种解决办法

    1、使用MyIsam引擎

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

    2、修改My.cnf配置文件

    首先确认是否是使用Innodb引擎,如果不是那就参考第一种办法,innodb中可以通过innodb_file_format设置为Barracuda,Barracuda中支持 ROW_FORMAT=COMPRESSED

    对于mysql版本 5.1 表类型

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

    对于mysql版本 5.5 表类型

    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服务,并重新创建表

    3、使用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, 则支持。

  • 相关阅读:
    使用javaDate类代数据仓库维度表
    Hermes和开源Solr、ElasticSearch 不同
    MapReduce 异常 LongWritable cannot be cast to Text
    吐槽CSDN编辑
    Codeforces 452A Eevee
    看不清楚未来,请做好如今
    JDBC数据库连接
    mixpanel实验教程(2)
    使用jquery+一般处理程序异步载入信息
    Eclipse中的Maven项目报Unbound classpath variable错误
  • 原文地址:https://www.cnblogs.com/andy-0212/p/9805558.html
Copyright © 2020-2023  润新知