问题描述
我试图将一些数据插入数据库,但出现此错误"发送QUERY数据包时出错"
i was trying to insert some data into the database but i got this error "Error while sending QUERY packet"
$insertDeta = $conPat->prepare("insert into table1(data) VALUES(:data)");
$insertDeta->bindParam(':data',$data);
$conPat->beginTransaction();
$insertDeta->execute();
$conPat->commit();
但是我认为问题在于数据的大小超过16MB.
该列的数据类型设置为 longtext ,我认为它可以保留高达4GB的数据.
but what i think the problem is that size of the data is over 16MB.
the data type of the column is set as longtext, which i think can keep data as big as 4GB.
我不知道PDO在运行查询或将16MB数据传输到数据库时是否遇到问题.
那就是我做的唯一猜测,因为mysql可能会在数据包中发送数据,而数据包无法保存最大16MB的数据.
I dont know if PDOs is having problems running the query or transfering 16MB of data to the database.
Thats the only guess i can make as mysql might send the data in packets and the packet cannot hold data as large as 16MB.
推荐答案
您猜对了,MySQL在数据大小方面存在限制,您需要将查询分成几组记录,或者可以使用SET GLOBAL max_allowed_packet=524288000;
更改max_allowed_packet
You guessed right MySQL have limitation for size of data, you need to break your query in small group of records or you can Change your max_allowed_packet by using SET GLOBAL max_allowed_packet=524288000;
这篇关于发送QUERY数据包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!