PHP:MySQL服务器已不复存在 [英] PHP: MySQL server has gone away
问题描述
我知道这个问题已经问过很多遍了,但是我已经尝试了一切.
I know this question has been asked numerous times but I've tried everything.
我有一个PHP脚本,可以遍历数千个图像,并在必要时执行大小调整,然后插入数据库中.
I have a PHP script that iterates through thousands of images, performs resizing if necessary and then inserts into the database.
我收到此错误消息:
警告:mysql_query()[function.mysql-query]:MySQL服务器已消失 在第105行的C:\ Utilities \ server \ htdocs \ newGen \ index.php中消失
Warning: mysql_query() [function.mysql-query]: MySQL server has gone away in C:\Utilities\server\htdocs\newGen\index.php on line 105
警告:mysql_query()[function.mysql-query]:读取结果错误 行的C:\ Utilities \ server \ htdocs \ newGen \ index.php中的set头 105
Warning: mysql_query() [function.mysql-query]: Error reading result set's header in C:\Utilities\server\htdocs\newGen\index.php on line 105
我正在使用Xampplite,因此php.ini的某些部分丢失了,而其他部分则用于解决此问题,因为它们未使用lite版本.
I'm using Xampplite and so some parts of the php.ini are missing that others have used to solve the problem because they're not using the lite version.
我确定问题不是超时.尽管脚本将运行几分钟,但它会跳过已经处理过的图像,因此我很快会在大约10秒钟内收到错误消息.也许这与最大表大小有关?我无法在php.ini中找到任何可控制此内容的东西.
I'm certain the problem is not timeouts. While the script will run for several minutes it skips over images that have already been processed and so I quickly get the error message within about 10 seconds. Maybe this has something to do with max table size? I can't find anything in my php.ini that controls this.
非常感谢所有帮助,我已经花了几个小时了.
All help is greatly appreciated, I've been going at this for hours now.
这是位于105标记处的代码,它是查询:
Here is the code at the 105 mark, it's the query:
// Add tNail and image to db
mysql_query("INSERT INTO gallery values('','$hash','$thumbBlob','$imageBlob','$type','','0','0.0')");
// $q->execute();
print "Successfully processed $fileName<br>";
从注释中可以看出,我对此尝试了PDO并得到了相同的错误,愚蠢的我以为回到mysql_命令会有所帮助.
As you can see by the comments I tried PDO with this and got the same error, foolishly I thought going back to mysql_ commands would help.
如果有帮助的话,脚本每次都会在同一张图片上抱怨,但是每张图片最多只有几十个千字节,最多只有几百个字节.
If it's of any help the script complains at the same image every time, yet each image is only ever a few tens of kilobytes and a couple hundred at the most.
推荐答案
在my.cnf
MySQL配置文件中检查"max_allowed_packet
"的值.
Check the value of "max_allowed_packet
" in your my.cnf
MySQL config file.
这篇关于PHP:MySQL服务器已不复存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!