Search code examples
c#mysqlarraysblobblobstorage

MySQL data is too long for column occuring on LONGBLOB


I have the following MySQL (version 5.1) table (InnoDB):

Username varchar(50)  
Sequence int(11)  
FileType varchar(10)  
Photo longblob -- here
PhotoSize int(11)  
Timestamp datetime

Attempting to insert a byte[] 96.7KB fails with the error:

Data Too Long For Column 'Photo' At Row 1

Inserting byte[] (size 37.2KB) works fine. I don't know what the tipping point is.

I googled it and many said the solution was to change it from BLOB to LONGBLOB. This didn't work. Others said changing to Max_Allowed_Packet to 16M (in the my.ini file) would solve the problem. This also didn't work.

Can anyone help me?


Solution

  • Even if they "can", databases are not made to stock binary files. It's more efficient to have in your table the path of the files on your server.