MySQL ERROR 1118: Row size too large appears when a table definition, or a single row, does not fit one of two limits: the InnoDB limit of roughly half a page (the familiar > 8126) or the server-wide limit of 65,535 bytes. They share an error number but need different fixes, so start by reading which one you got.
-- InnoDB page limit
ERROR 1118 (42000): 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.
-- MySQL server limit
ERROR 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
The server error reference lists 1118 as ER_TOO_BIG_ROWSIZE, SQLSTATE 42000. The text with 65535 is the server limit. The text with > 8126 comes from InnoDB, and its last sentence tells you the row format: a 768-byte BLOB prefix means COMPACT or REDUNDANT, a 0-byte prefix means DYNAMIC.
Limit 1: 65,535 bytes for the whole row
The MySQL manual is blunt: the internal representation of a table has a maximum row size of 65,535 bytes, whatever the storage engine can do. Every column counts with its maximum byte length plus length bytes. A VARCHAR(10000) in utf8mb4 reserves up to 40,000 bytes, because one character can take four bytes, so two such columns are already too many. TEXT and BLOB columns contribute only 9 to 12 bytes, because their contents are stored separately.
The fix for this variant is always the same: turn the largest VARCHAR columns into TEXT (or VARBINARY into BLOB), or shrink their declared length to what the data actually needs. Changing the row format does nothing here.
Limit 2: about half an InnoDB page
InnoDB keeps rows in B-tree pages. The InnoDB limits page puts the maximum row size, not counting variable-length columns stored off-page, at slightly less than half a page for 4KB to 32KB pages. With the default 16KB innodb_page_size that is the 8126 bytes in the message. When a row is longer, InnoDB moves variable-length columns to overflow pages until the rest fits. How much stays behind depends on the row format:
- COMPACT and REDUNDANT keep the first 768 bytes of each long column in the row. Ten long
TEXTcolumns can therefore pin about 7.5KB on the page by themselves, which is why old tables with many text fields hit 1118. - DYNAMIC, the default value of
innodb_default_row_format, can move a long value fully off-page, leaving only a 20-byte pointer.TEXTandBLOBvalues of 40 bytes or less stay inline. - Fixed-length columns of 768 bytes or more, such as
CHAR(255)inutf8mb4, are encoded as variable-length and can also move off-page.
The trap: short columns cannot leave the page
Off-page storage only helps if InnoDB is allowed to move the column. In the InnoDB source (data0type.h), a column qualifies as "big" when its maximum length is over 255 bytes or it is a BLOB-type column. A VARCHAR(50) in utf8mb4 has a maximum of 200 bytes, so it always stays in the row. The manual's own example is a DYNAMIC table with 33 CHAR(255) columns in latin1: CREATE TABLE fails with 1118, and the message says the BLOB prefix is 0 bytes. Dozens of short utf8mb4 VARCHAR columns run into the same wall.
This also explains a confusing pattern we see in production: the CREATE TABLE succeeds, the application runs for months, and then one INSERT or UPDATE fails with 1118. In our experience it is usually a row where many short columns are full at once, often with multibyte or emoji text, so the actual byte count crosses the limit that the column definitions only made possible.
What innodb_strict_mode changes
innodb_strict_mode is ON by default. With it, InnoDB runs a row size check during CREATE TABLE and ALTER TABLE and returns an error. With it off, the same table is created with a warning (code 139), and the error moves to the first INSERT or UPDATE that builds a row that is too large. Turning strict mode off is not a fix; it hides the problem until production data trips over it.
Two related situations produce the same error:
- Restoring an old dump. A wide table created long ago with strict mode off and an explicit
ROW_FORMAT=COMPACTcan fail to restore on a new server where strict mode is on. Remove or replace the clause and restore again. - Adding columns instantly. The online DDL documentation notes that MySQL checks the row size when
ALGORITHM=INSTANTadds a column and refuses if the new maximum would cross the limit, suggestingINPLACEorCOPY. Those algorithms are still subject to the same limits.
Fixing it, in order
- Check page size, strict mode and the table's row format.
SELECT @@innodb_page_size, @@innodb_strict_mode, @@innodb_default_row_format; SELECT TABLE_NAME, ROW_FORMAT FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'app' AND TABLE_NAME = 'customer_profile'; SHOW CREATE TABLE app.customer_profile\G - If the table is COMPACT or REDUNDANT, convert it to DYNAMIC. This is an in-place rebuild that allows concurrent reads and writes, and in most legacy cases it is the whole fix.
ALTER TABLE app.customer_profile ROW_FORMAT = DYNAMIC, ALGORITHM = INPLACE, LOCK = NONE; - If it is already DYNAMIC, change the columns. Turn long, rarely filtered columns into
TEXTorBLOB, or move them into a one-to-one side table. Shrinking a declared length helps against the 65,535-byte limit, but a column that drops to 255 bytes or less can no longer move off-page. - Re-check after charset changes. Converting from
utf8mb3toutf8mb4raises the maximum byte length of every character column by a third, which is a common way to cross both limits. The ERROR 1366 Incorrect string value guide covers the charset side. - Do not reach for innodb_page_size. It can only be set before the instance is initialised. Changing it means a new instance and a full logical reload, which is rarely worth it for one wide table.
The 768-byte prefix is the giveaway. If the message ends with "BLOB prefix of 768 bytes is stored inline", the table is not DYNAMIC. Convert the row format first; only redesign columns if the error survives the conversion.
On large tables
On a small table each of these changes takes seconds. On a table with hundreds of gigabytes, each is a full rebuild, and the details decide whether it is a quiet maintenance task or an incident.
- Inventory first. Find every table still on an old format, with its size, before one of them breaks an insert in production.
-- tables still on the old formats
SELECT TABLE_SCHEMA, TABLE_NAME, ROW_FORMAT,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS size_mb
FROM information_schema.TABLES
WHERE ENGINE = 'InnoDB'
AND ROW_FORMAT IN ('Compact', 'Redundant')
ORDER BY size_mb DESC;
- Disk space. A rebuild writes an intermediate
#sql-ibfile in the same directory as the table, which may need as much space as the original table.innodb_tmpdirdoes not apply to that file, so the data volume must have the room. - The online log. Writes during an online rebuild go to a temporary log capped by
innodb_online_alter_log_max_size(128MB by default). If a busy table outgrows it, theALTERfails and uncommitted concurrent DML is rolled back. The variable is global: raise it before the rebuild or schedule the rebuild for a quiet window. - Column type changes block writes.
VARCHARtoTEXTis a data type change, which the manual lists asALGORITHM=COPYonly, without concurrent DML.
-- changing a column type is COPY only: writes are blocked for the whole rebuild
ALTER TABLE app.customer_profile
MODIFY notes TEXT, ALGORITHM = COPY;
- On a large, busy table use an online schema change tool instead of a plain
ALTER. Our guide to ALTER TABLE without downtime compares the options. - Replicas. In our experience the replica applies a long
ALTERonly after the primary finishes, and replication lag grows for about as long as the rebuild took. Plan for it, or roll the change through replicas first. - Find the rows that are close. If 1118 happens on
INSERT, list the widest existing rows to see how much headroom is left. On a big table this is a full scan, so run it on a replica.
-- the widest rows by bytes stored in short columns (full scan: run it on a replica)
SELECT id,
COALESCE(LENGTH(first_name), 0) + COALESCE(LENGTH(last_name), 0)
+ COALESCE(LENGTH(city), 0) + COALESCE(LENGTH(street), 0) AS bytes
FROM app.customer_profile
ORDER BY bytes DESC
LIMIT 20;
Moving columns off-page fixes the error but is not free. Each off-page value is another page read when the query needs it. In our experience the best long-term shape for very wide tables is a narrow main table with the hot columns and a side table for large or optional fields, so that the common queries never touch the overflow pages.
Key takeaways
- ERROR 1118 covers two limits: 65,535 bytes for the whole row (fix with
TEXT/BLOB) and about half an InnoDB page, 8126 bytes on 16KB pages. - A 768-byte BLOB prefix in the message means COMPACT or REDUNDANT.
ROW_FORMAT=DYNAMICis an in-place rebuild and usually fixes it. - Columns with a maximum of 255 bytes or less never move off-page, so many short
utf8mb4columns can fail even in DYNAMIC. - Turning off
innodb_strict_modeonly moves the error fromCREATE TABLEto a laterINSERT. - On big tables check disk space and the online log size, and use an online schema change tool for type changes, which are copy-only.