发送 QUERY 数据包时出错 [英] Error while sending QUERY packet
问题描述
我试图向数据库中插入一些数据,但我收到此错误发送查询数据包时出错"
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 对数据大小有限制,您需要在小记录组中打破您的查询,或者您可以使用 更改您的 max_allowed_packet设置全局 max_allowed_packet=524288000;
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 数据包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!