File size limit on MySQL blob type

I’m working through Paul DuBois’ book “MySQL and Perl for the Web”. I’m trying his example in chapter 5, “Storing and Retrieving Images”, in which he shows how to shove images into MySQL items typed as blobs. I didn’t know you could do that, and I hear that it is debatable whether that is an efficient way to store images as opposed to storing just a pointer to the image files. But I’m wondering why I seem to be hitting a file size limit. Is it the script or the host? If I use one of his example images like balloons.jpg, it seems to retrieve in full, but my images brake.jpg or tiger.jpg seem to be a little truncated. see:



:cool: Perl / MySQL / HTML+CSS

This is why I wish people would post answers instead of just links. Both of the links in the previous answer are now dead, which invalidates the usefulness of these posts to future audiences.

Post links as well, but at least answer the basic question in the reply.


Robert Porter

Here is what you do in this case. The site itself is live, so take the words “String_types” and “BLOB” and put them in the search box in the top right corner of the page. You learn that they have pages in every manual and all versions are available.


This seems to be the only post I can find similar to my issue.

I have a MEDIUMBLOB and have perl $CGI::POST_MAX set to 50MB for development/testing; although this is likely to be larger in final state. I am receiving a “Got a packet bigger than ‘max_allowed_packet’ bytes” error when attempting to form upload (via curl) a 29MB file, a 12MB file works fine. Logging into my db mysql from terminal the variable max_allowed_packet% is set to 16777216 by default. Are we truly limited to 16MB uploads? In other posts it seems that Dreamhost does not allow us to override with a user my.cnf configuration. How can I get around this or what am I doing wrong?

Thank you!

You’re correct; this limit exists on the MySQL server side, and cannot be overridden. Sorry.

We do not recommend that you use MySQL databases for file storage. Uploaded files should generally be stored as files on the web server, not in a MySQL database. The MySQL server often doesn’t have as much storage available as the web server, and cannot deliver it to users as quickly as the web server can.

Ok. I will update my code to save to the file system instead. Thank you for the quick response!