I have a mysql db. I use innodb. 0ne of my tables contains a little more than 10 columns. The last column has a type of LONGTEXT and it is supposed to contain html code. The problem is, for each record, that field does not conatin the full code and it stops always after the same amount of characters. The weight of the html files I try to insert is around 60KO. So I guess each of my record exceeds the row size limit of mysql (66KO). What I would like to know is if there are some ways to extand that limit. Any workaround would be much appreciated. Thanks in advance for the inputs. Cheers. Marc
5 Answers
The accepted answer is wrong (or at least pretty opinionated) - I don't personally want data stored outside of my database, as it creates complications in terms of backup procedures and transactional queries.
As others have pointed out, the manual repeatedly states that BLOB and TEXT columns do not count towards the total row-size, but unfortunately, with the default configuration settings, that's not true, and you end up getting this error-message. (The error-message doesn't make any sense, because it's telling you to use TEXT instead of VARCHAR to address the issue - which you already are.)
The reason for this limitation is the default storage mechanism, Antelope, which stores the first 768 bytes of variable-length columns in the row - and a possible solution is to use INNODB and switch your storage mechanism to the alternative Barracuda storage mechanism:
SET GLOBAL innodb_file_format=Barracuda;
This will have no immediate effect, because this setting is a default for new database files - so you will need to drop and recreate your entire database.
Alternatively, switch to Barracuda (as above) and then (in addition) switch to the file-per-table strategy:
SET GLOBAL innodb_file_per_table=ON;
Again, this will have no immediate effect, because both settings are defaults for new tables - so again, you will need to drop and recreate the table.
If you look in the MySQL data folder after doing this, you can confirm that separate files were created, e.g. for a database named "data", and a table named "test", you should see a file named "data/test/bigtable.ibd".
If you dislike changing the global settings in MySQL, try SET SESSION
instead of SET GLOBAL
, e.g. immediately before running your CREATE TABLE
statements.

- 18,769
- 10
- 104
- 133

- 7,085
- 3
- 44
- 54
-
1This should be the accepted answer, its worth noting that you can `ALTER` your already-created tables to use file storage. [docs](http://dev.mysql.com/doc/refman/5.5/en/innodb-compression-usage.html) – tonyjmnz Mar 18 '14 at 13:57
-
It might be worth editing your answer to include the reason why the default configuration settings act the way they do. From the MySQL docs here (http://dev.mysql.com/doc/refman/5.5/en/innodb-row-format-antelope.html), the reason is that (at least for now) the default INNODB file format is Antelope which stores the first 768 bytes of variable-length columns in the row. If the default format ever changes this workaround may no longer be necessary. – nextgentech May 25 '15 at 20:49
Values for (LONG)TEXT (and BLOB) are not stored "in the row" but outside of it. Therefor the size of your HTML does not contribute to the size of the individual rows.
From the manual:
The internal representation of a table has a maximum row size of 65,535 bytes, even if the storage engine is capable of supporting larger rows. This figure excludes BLOB or TEXT columns, which contribute only 9 to 12 bytes toward this size
For BLOB and TEXT data, the information is stored internally in a different area of memory than the row buffer.
(emphasis mine)
http://dev.mysql.com/doc/refman/5.5/en/storage-requirements.html

- 1
- 1
When you say "that field does not conatin the full code and it stops always after the same amount of characters", how are you determining what the field contains? I suspect what you're viewing has been truncated by the max_allowed_packet
variable.
As stated in the MySQL manual:
The maximum size of a
BLOB
orTEXT
object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications buffers. You can change the message buffer size by changing the value of themax_allowed_packet
variable, but you must do so for both the server and your client program. For example, bothmysql
andmysqldump
enable you to change the client-sidemax_allowed_packet
value. See Section 8.11.2, “Tuning Server Parameters”, Section 4.5.1, “mysql
— The MySQL Command-Line Tool”, and Section 4.5.4, “mysqldump
— A Database Backup Program”. You may also want to compare the packet sizes and the size of the data objects you are storing with the storage requirements, see Section 11.5, “Data Type Storage Requirements”

- 122,705
- 18
- 212
- 237
There is no way to extend this limit, as it is not dependent on the storage engine but it is a hard limit on the server:
Every table (regardless of storage engine) has a maximum row size of 65,535 bytes. Storage engines may place additional constraints on this limit, reducing the effective maximum row size.
In this case the solutions should revolve around deferring the storage of HTML to some other place - on the filesystem or on the cloud (S3) and then refer to the file name in the table column.

- 169,990
- 18
- 245
- 284
-
7This limit does not apply to the `BLOB` and `TEXT` types. http://dev.mysql.com/doc/refman/5.5/en/blob.html – eggyal Apr 27 '12 at 11:07
-
hello burhan. thanks for the workarounf idea (saving on the filesystem). I will do that if I do not find another solution... – Marc Apr 27 '12 at 11:11
-
1You are right, but I still stand by my recommendation of storing "file like" content outside of the database. – Burhan Khalid Apr 27 '12 at 11:11
-
That 64KB limit is irrelevant. That is an internal limit; Neither MyISAM, nor InnoDB is limited to it. Here is a relatively comprehensive list of limits: http://mysql.rjweb.org/doc.php/limits – Rick James Apr 28 '20 at 05:31
We resolved it with following below steps.
Step-1: Run below queries into MySql to set global variables.
- SET GLOBAL innodb_file_format=Barracuda;
- SET GLOBAL innodb_file_per_table=ON;
Step-2: Select table from which the error occur when you trying to save large data into single row.
Step-3: Go to Operations
Step-4: Select COMPRESSED from ROW_FORMAT. (By default COMPACT and REDUNDANT will be there when you set global variables innodb_file_format and innodb_file_per_table you can find another options like COMPRESSED and DYNAMIC)
Step-5: Click Go.
:)

- 39
- 1
- 5