Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Tjyoung's avatar
Level 14

Max_packet_size is exceeded

Hi, getting an error when uploading a file into my DB that the max_packet_size has been exceeded. Trying to figure out how/where to up it? Any suggestions would be helpful/appreciated. Thanks

0 likes
10 replies
Snapey's avatar

Its not a good idea to store files in your database. How large is it?

automica's avatar

How big is the file? Would it be better to save the file in storage and then provide a link to it in the db?

Tjyoung's avatar
Level 14

Its a json return from an API (vehicle color codes/urls). Not sure how to check current limit. Must be just over as I've inserted hundreds very similiar so suspect this is just slightly over the max amount

Tjyoung's avatar
Level 14

I'm basically storing a list of style ID's for vehicles to keep from having to hit the API. So each style ID has its corresponding json in a column. So when listing a page of vehicles, I need not go to the API for each one as it takes too long.

KalimeroMK's avatar

just add the memory you need to the sql server bud its not smart to store files in db

max_allowed_packet=500M

of if dont whont to edit .ini file just run the command change the max allowed packet for everyone to 1GB


SET GLOBAL max_allowed_packet=1073741824;

form slq terminal but this temporaly until the server restarts:

Snapey's avatar

look at the size of the existing payloads

Tjyoung's avatar
Level 14

Ok will look at the file size What I’m wondering is, is the packet size revering you the actual csv file I’m uploading into the DB? Or is it one particular row that is too big? Not sure what the packet actually is

Snapey's avatar

Its the amount of data that can be sent to the sql server in one request

Tjyoung's avatar
Level 14

Think I explained myself poorly when posting.

I was actually seeding the table with a csv that was roughly 150megs so when uploading to the DB it gave the warning.

Once realizing the packet size was referring to the actual file size I was uploading, I just split it in two and all is fine.

Once seeded I just do incremental updates of a couple rows here and there as new style ID's come available. Thanks for taking the time to respond and apologize for my weak initial posting of the issue.

Please or to participate in this conversation.