Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql error: Row size too large (& gt; 8126).

Shulou Source: shulou.com Published: 2022-06-01 18:37:00 10月03日 Update

Mysql version: mysql 5.6

Mysql engine: default InnoDB

The reason for the problem: due to the fact that a defined role information table has nearly 300 columns, and most of them are blog data types, the data storage times is wrong:

Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help

Problem analysis:

You may want to take a look at this article which explains a lot about MySQL row sizes. It's important to note that even if you use TEXT or BLOB fields, your row size could still be over 8K (limit for InnoDB) because it stores the first 768 bytes for each field inline in the page.

The simplest way to fix this is to use the Barracuda file format with InnoDB. This basically gets rid of the problem altogether by only storing the 20 byte pointer to the text data instead of storing the first 768 bytes.

Solution:

1. Modify mysql configuration file my.cnf

Innodb_file_per_table

Innodb_file_format = Barracuda

2. Modify the table properties that caused the problem

ALTER TABLE $TABLE

ENGINE=InnoDB

ROW_FORMAT=COMPRESSED

KEY_BLOCK_SIZE=8

3. Restart the mysql service

4. By writing sql statements to modify the mysql environment configuration, you can avoid restarting the service. Of course, the above two parameters must also be configured in the configuration file, which is just to avoid this restart of the mysql service.

Mysql > set global innodb_file_per_table = ON

Mysql > SET GLOBAL innodb_file_format = barracuda

Tags: Configuration problem service data file two information reason parameter just property engine method times version environment type role statement analysis Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple OPPO Reno Redmi macOS MySQL