Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:50:12+00:00 2026-06-07T03:50:12+00:00

I am storing images in MYSQL. I have table as CREATE TABLE myTable (id

  • 0

I am storing images in MYSQL.

I have table as

CREATE TABLE myTable (id INT, myImage BLOB);

When I am trying to insert 4.7MB file, I am getting exception as

com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4996552 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.

I believe this is related to image size only. Is there any other variable type that I can use?


Update 1

As per older SO question, I also tried with MEDIUMBLOB but still I am getting same error.

Adding Image to a database in Java


Update 2

At the start of the project, I execute below query and everything is working now

SET GLOBAL max_allowed_packet = 1024*1024*14;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:50:13+00:00Added an answer on June 7, 2026 at 3:50 am

    As the error says, it has nothing to do with variable type but rather the max_allowed_packet variable:

    You must increase this value if you are using large BLOB columns or long strings. It should be as big as the largest BLOB you want to use. The protocol limit for max_allowed_packet is 1GB. The value should be a multiple of 1024; nonmultiples are rounded down to the nearest multiple.

    But, generally speaking, don’t store files in your database – store them in your filesystem and record the path to the file in the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a mysql database storing uploaded photos , i am trying to generate
I have created a MySQL table where one of the columns stores a BLOB
I am storing a few images in MYSQL for security reasons. When I download
The best way to store images into MySQL is by storing the image location
I'm storing banner ads in a mysql table or I should say just the
I have added an image into a MySql database. And I am trying to
I have a table where I'm inserting, for instance, images and the names of
I have a table in mysql databse with a boolean column (or tinyint(1)). In
Possible Duplicate: Storing Images in DB - Yea or Nay? For ages I've been
I just switched from storing my images uploaded via Carrierwave locally to using Amazon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.