157

What is the maximum length of data I can put in a BLOB column in MySQL?

Tiny
  • 24,933
  • 92
  • 299
  • 571
Newy
  • 34,169
  • 9
  • 40
  • 55
  • 1
    2^16 bytes, [apparently](http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html). Also: "The maximum size of a BLOB or TEXT 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." – Zabba Apr 25 '11 at 05:45
  • Take a look at http://stackoverflow.com/a/6766854/1358777 – Alwin Kesler Jun 09 '16 at 17:37
  • Incredibly, the Mysql docs do not directly provide this info. The closest I've found is the "Storage Required" formula which only implies the answer, once you compute it: "L + 2 bytes, where L < 2^16" – Dogweather May 22 '18 at 21:54

3 Answers3

259

A BLOB can be 65535 bytes (64 KB) maximum.

If you need more consider using:

  • a MEDIUMBLOB for 16777215 bytes (16 MB)

  • a LONGBLOB for 4294967295 bytes (4 GB).

See Storage Requirements for String Types for more info.

Alain Tiemblo
  • 32,952
  • 14
  • 114
  • 147
WhiteFang34
  • 66,579
  • 17
  • 101
  • 108
  • 62
    In other words, `BLOB` ≈ 64KB, `MEDIUMBLOB` ≈ 16MB and `LONGBLOB` ≈ 4GB – IvanRF Oct 09 '15 at 16:02
  • 1
    I am using medium blob, but it accepts till 1MB data only. Why? Is there anywhere I have to set this size? – SIBHI S Feb 20 '20 at 09:46
18

May or may not be accurate, but according to this site: http://www.htmlite.com/mysql003.php.

BLOB A string with a maximum length of 65535 characters.

The MySQL manual says:

The maximum size of a BLOB or TEXT 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

I think the first site gets their answers from interpreting the MySQL manual, per http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

Chris
  • 48,555
  • 16
  • 95
  • 112
Tieson T.
  • 20,030
  • 4
  • 69
  • 86
4

A BLOB can be 65535 bytes maximum. If you need more consider using a MEDIUMBLOB for 16777215 bytes or a LONGBLOB for 4294967295 bytes.

Hope, it will help you.