MySQL:SQL 错误 [1118] [42000]: Row size too large.

发布时间 2023-07-05 13:45:03作者: 十三年新

1.场景:

今天在用MySQL建表的时候,报了一个错误;

SQL 错误 [1118] [42000]: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs

2.原因:

从字面的意思理解就是所用表类型(不包括 BLOB)的最大行大小为 65535。您必须将某些列更改为TEXT或 BLOBs;

1.如果数据库编码为utf8mb4,表所有varchar字段总长度(Length):Length*4不能大于65535。

2.如果数据库编码为utf8,表所有varchar字段总长度(Length):Length*3不能大于65535。、

2.解决方案:

将建表SQL中varchar长度比较大(比如超过2000)的字段,类型修改为TEXT,避免总长度超过65535即可。