mysql数据库存储text字段报错maximum row size is 8126

当尝试在MySQL中存储大text字段时,遇到错误1118,原因是表的ROW_FORMAT为Compact,超过了8126字节限制。解决方法包括在配置文件中设置innodb_file_per_table=1,重启MySQL服务,确保InnoDB文件格式为Barracuda。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[Err] 1118 - Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs

参考:https://blog.youkuaiyun.com/lsjseu/article/details/51887991

问题:
text字段存储大字段也会报错

原因:
表的ROW_FORMAT = Compact导致
(创建表时指定:ENGINE=InnoDB AUTO_INCREMENT=771 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPRESSED,但是ROW_FORMAT还是Compact,查询可知:SHOW TABLE STATUS LIKE 'mtymentinfo%';

想要设置ALTER TABLE mtymentinfo ROW_FORMAT = COMPRESSED但是不生效

解决:
查看show variables like '%per_table%';
如果是off或者0表示关闭

开启方法:
1、打开mysql的配置my.ini。在innodb配置出添加:innodb_file_per_table=1
(在my.cnf中[mysqld]下设置innodb_file_per_table=1)

#switch on the independent table space by setting  'ROW_FORMAT = COMPRESSED'
innodb_file_per_table=1
innodb_file_format=barracuda

#avoid problem "MySQL server has gone away With statement"
#max_allowed_packet=1024M

查看是否开启(重启mysql服务):
show variables like ‘%per_table%’;

2、show GLOBAL VARIABLES LIKE ‘%file_format%’;
查看value是否是Barracuda
不是的话:

set GLOBAL innodb_file_format = 'Barracuda';

set GLOBAL innodb_file_format_max = 'Barracuda';

3、ALTER TABLE mtymentinfo ROW_FORMAT = COMPRESSED
修改成功!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值