简体   繁体   English

尝试将大文件.txt导入MysQL时出现错误500

[英]Error 500 when trying to import large file .txt to MysQL

We're using Yii framework for an internal tool. 我们正在使用Yii框架作为内部工具。

What we have now : The user select a file .txt to upload on the server. 我们现在拥有的内容:用户选择一个.txt文件上传到服务器上。 The server clean the text file because it containts lots of characters such as """ and ;;;; 服务器清理文本文件,因为它包含许多字符,例如“”和;;;。

But when comes the time to import to database, server sends a 500 internal error with no more information. 但是,当需要导入数据库时​​,服务器将发送500个内部错误,没有更多信息。

The file size is 8.1 mo. 文件大小为8.1个月。 The import seems to work if we delete manually some rows in order to make the file at less than 7 mo. 如果我们手动删除一些行以使文件小于7 mo,则导入似乎可以正常进行。

We took a look at the php.ini file and increased all the limits. 我们查看了php.ini文件,并增加了所有限制。

What is weird is that we made local server with easyphp (same config in php.ini) and it works. 奇怪的是,我们使用easyphp(php.ini中的相同配置)制作了本地服务器,并且可以正常工作。

Do you have an idea ?? 你有想法吗 ??

Thanks ! 谢谢 !

With the information's you have provided, I can only suggest that turn on error_reporting and display_errors in your php.ini file. 根据您提供的信息,我只能建议您在php.ini文件中打开error_reporting和display_errors。 Increase maximum execution time and then see if any error displays or not? 增加最大执行时间,然后查看是否显示任何错误?

Also do you have access to your log files in server? 您还可以访问服务器中的日志文件吗? Then check php error_log for more information. 然后检查php error_log以获取更多信息。

Do you have some error logging (preferably written on the server, as the 500 pages generally not show the error). 您是否有一些错误日志记录(最好写在服务器上,因为500页通常不会显示该错误)。

Many servers are configured to return a 500 internal error in case of an error in a mysql_query. 许多服务器被配置为在mysql_query错误的情况下返回500内部错误。 So either there is omewhere in the 8MB in issue (which does not appear to be the case, if it works in exactly the same table on another server), or the query is too long (increasing the limits is not always possible on a shared server). 因此,要么8MB内存在问题中(如果它在另一台服务器上的完全相同的表中工作,就不会出现这种情况),或者查询时间太长(在共享服务器上不一定总会增加限制)服务器)。

If you share some code and/or error message that may help to find the issue. 如果您共享一些代码和/或错误消息,可能有助于发现问题。

There is also a limit on the SQL server, defined by max_allowed_packet . SQL服务器也有一个限制,由max_allowed_pa​​cket定义。 Please take a look on the result of 请看一下结果

show variables like 'max_allowed_packet';

Maybe this is set to low. 也许这被设置为低。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM