1. cliveportman
  2. /code
  3. /mysql-error-row-size-too-large-when-saving-fields-within-craft-cms

MySQL error "Row size too large." when saving fields within Craft CMS

Here's the error in full:

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1118 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

In this instance, the problem is the row size limits within MySQL. I tried compressing the content using https://stackoverflow.com/ques... but it made no difference because it isn't the content that's the problem. Instead it's the columns. This is from the MySQL docs:

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 and TEXT columns only contribute 9 to 12 bytes toward the row size limit because their contents are stored separately from the rest of the row.

My solution then was to remove character limits of 255 or less so VARCHAR() columns were re-saved as TEXT columns.