mysql之Row size too large (> 8126)問題解決方案
問題描述:
項目中涉及文本存儲(mysql數據庫中設置為text),如果要存儲的數據過大,項目中報錯如下:
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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. ### The error may exist in file [E:\fjt\2020\workspace\SWAP_background_service\target\classes\mybatis\mapper\equipment_manage\HistoryMapping.xml] ### The error may involve com.liansheng.swap.mapper.equipment_manage.HistoryMapper.update-Inline ### The error occurred while setting parameters ### SQL: update swap_variable_history SET hour01 = ? WHERE deptid = ? and variableid = ? and collectorid = ? ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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.
解決方案:
1.設置mysql全局變量 設置命令:SET GLOBAL innodb_file_format='Barracuda';
檢查命令:show GLOBAL VARIABLES LIKE '%file_format%'; 2.設置對應表的屬性(行格式) alter table 表名 ROW_FORMAT=COMPRESSED
參考文章:https://blog.csdn.net/fallcreek/article/details/49495915