NYCPHP Meetup

NYPHP.org

[nycphp-talk] using PHP to import large-ish SQL into mysql

Daniel Horning dan.horning at planetnoc.com
Wed Oct 21 09:20:48 EDT 2009


the command line one is much faster 
 

 

mysql -uUSER -p DATABASETARGET < FILENAME

 

(will prompt you for your password)

 

--

Dan Horning

 

American Digital Services - Where you are only limited by imagination.

dan.horning at planetnoc.com :: http://www.americandigitalservices.com

1-518-444-0213 x502 . toll free 1-800-863-3854 . fax 1-888-474-6133

15 Third Street, PO Box 746, Troy, NY 12180 (by appointment only)

 

From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Damion Hankejh
Sent: Wednesday, October 21, 2009 9:09 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] using PHP to import large-ish SQL into mysql

 

Sounds familiar to an issue I had with uninformative 500 Internal Server
errors -- my script was timing out.  Check your max script execution time
with:

 

echo ini_get('max_execution_time');

 

Extend it with:

 

set_time_limit($seconds); // has no effect if running safe_mode

---
Damion Hankejh | hankejh.com



 

On Wed, Oct 21, 2009 at 5:02 AM, Marc Antony Vose <suzerain at suzerain.com>
wrote:


Le Oct 21, 2009 à 8:11 AM, Daniel Convissor a écrit :

 

Problem is, the PHP script is terminating with a PHP error; server's
support thinks it's out of memory.


Why should anyone be guessing what the issue is?  PHP's error messages
explain exactly what the problem is in plain English.  Please post the
actual error message.

 

Sorry...I made a typo there.  I  meant that the script is terminating with a
500 Error (NOT a PHP error)...which means there is no log or useful error
trail.  All I see in the error_log is the dreaded "Premature end of script
headers" error.

It usually points to out of memory or some other config error (like a bunk
shebang line in a CGI).

In this case, the script works when I import the smaller tables, and gives
the 500 Error when I try the larger tables, so I think out of memory is a
pretty reasonable hypothesis.

As I said, PHP's memory_limit is set to 90M by default (according to
phpinfo()) and I tried upping it to 128M, and phpinfo() says it's set to
that, also, so I'm a bit confused as to why one 16 MB file would exceed 90M
on import, but hey, who knows.





Another thought, if this is (nearly) all you're doing, why involvine PHP
at all?  Do it directly in a shell script.

 

I was using PHP partly because it's the language I'm most familiar with, but
more importantly because I don't want to automatically import certain files;
the decision to import is based on logic in the script, and some of that
logic comes from information in the bigger web application it's a part of.

I already rewrote the script in Perl, but still had issues with importing
the larger tables there, too.

I'm not really much of a shell scripter; perhaps I should see if I can do it
that way.

If anyone has any other strategy that can work in PHP, let me know.

Cheers,
Marc




_______________________________________________
New York PHP Users Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/Show-Participation

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20091021/f79297c8/attachment.html>


More information about the talk mailing list