Home >Database >Mysql Tutorial >How to Resolve MySQL Error 1118: 'Row size too large' When Creating Tables with Many Columns?

How to Resolve MySQL Error 1118: 'Row size too large' When Creating Tables with Many Columns?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2025-01-04 11:31:35217browse

How to Resolve MySQL Error 1118:

Error: Row Size Too Large in MySQL (Error Code: 1118) When Creating a Table with 325 Columns

When attempting to create a MySQL table with a large number of columns (325 in this case), users may encounter the "Error Code: 1118 Row size too large" error. This error occurs when the total size of the data in the table row exceeds the maximum row size allowed by the database.

To resolve this issue, several measures can be taken:

  1. Change Columns to TEXT or BLOB: The error message suggests converting columns to TEXT or BLOB data types to reduce their storage size. TEXT and BLOB data types are designed for storing large amounts of unstructured or binary data, respectively.
  2. Enable Barracuda File Format: By adding the innodb_file_format=Barracuda setting in the MySQL configuration file (my.ini), users can switch to the Barracuda file format. Barracuda is a newer file format that offers improved performance and supports larger row sizes compared to the traditional InnoDB file format.
  3. Disable Strict Mode: The innodb_strict_mode setting can be disabled to allow for the creation of tables that exceed the maximum row size. However, note that disabling strict mode may compromise data integrity in some cases.

In the provided example, the user replaced VARCHAR columns with TEXT and enabled Barracuda, but the error persisted. The issue was eventually resolved by setting innodb_strict_mode=0 to disable strict mode. This allowed the table to be created successfully despite exceeding the maximum row size limit. It's important to note that disabling strict mode should be considered a last resort due to its potential implications on data integrity.

The above is the detailed content of How to Resolve MySQL Error 1118: 'Row size too large' When Creating Tables with Many Columns?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn