MYSQL ERROR 1118
创建新表时报错:
ERROR 1118 (42000): Row size too large (> 4030). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.
该表在另一个数据库已经存在,但当前库创建报错,所以有点疑问.
查阅官方文档:发现InnoDB表row size和innodb page size有关;
-
The internal representation of a MySQL table has a maximum row size limit of 65,535 bytes, even if the storage engine is capable of supporting larger rows.
BLOB
andTEXT
columns only contribute 9 to 12 bytes toward the row size limit because their contents are stored separately from the rest of the row. -
The maximum row size for an
InnoDB
table, which applies to data stored locally within a database page, is slightly less than half a page for 4KB, 8KB, 16KB, and 32KBinnodb_page_size
settings. For example, the maximum row size is slightly less than 8KB for the default 16KBInnoDB
page size. For 64KB pages, the maximum row size is slightly less than 16KB. See Section 14.23, “InnoDB Limits”.If a row containing variable-length columns exceeds the
InnoDB
maximum row size,InnoDB
selects variable-length columns for external off-page storage until the row fits within theInnoDB
row size limit. The amount of data stored locally for variable-length columns that are stored off-page differs by row format. For more information, see Section 14.11, “InnoDB Row Formats”. -
Different storage formats use different amounts of page header and trailer data, which affects the amount of storage available for rows.
第二段大致意思:对于4KB、8KB、16KB和32KB InnoDB_页面大小设置来说略小于半页。例如,对于默认的16KB InnoDB页面大小,最大行大小略小于8KB。对于64KB页面,最大行大小略小于16KB。
然后对比两个库得innodb_page_size参数发现创建成功得是16KB,报错得是8KB,坑!!!
innodb_page_size
can only be configured prior to initializing the MySQL instance and cannot be changed afterward. If no value is specified, the instance is initialized using the default page size.
然后这个只能通过初始化得时候配置,后面不能修改;
之后通过以下步骤修改page size(1.5T得数据,很烦):
停机时间长得做法:
逻辑导出数据
重新初始化数据库
逻辑导入数据
停机时间短做法:
额外弄个服务器新建数据库innodb_page_size为16K
源库mydumper导出数据
新库导入数据
主从同步
主从切换
然后源数据库重建
xtrabackup新得主库
源服务器用xtrabackup还原做从库
主从切换
额外服务器资源回收
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY