News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sameer Borate's Blog:
Splitting large MySQL dump files
October 03, 2011 @ 08:44:43

In a new post to his blog Sameer Borate includes a handy bit of code you can use to split up a large MySQL dump file into smaller, easier to digest chunks.

One of the frustrating things with working with MySQL is of importing large sql dump files. Either you get a 'max execution time exceeded' error from PHP or a 'Max_allowed_packet_size' from MySQL. In a recent task I needed to import a table of around a million records on a remote host, which quickly became an exercise in frustration due to various limitations on the server. SSH was of no help as changing the configuration files was restricted to the root user. My last resort was to split the huge 'INSERT' statements into smaller size files.

His script needs a little extra time to run (he sets max execute to 600 seconds) and takes the SQL file in line by line, splitting them back out to over files based on a "count" value - "dump-split-*". Depending on the size of your files, using something like this might not be an option. You might need something more like the command line "split" feature to keep it outside of PHP's memory management all together.

0 comments voice your opinion now!
mysql sql dump file split unix multiple tutorial


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso: Bundles in Silex using Stack

Henrik Bjørnskov's Blog: Stampie an in depth look

Jonathan Snook's Blog: Multiple Validation Sets in CakePHP 1.2

Justin Carmony's Blog: Setting Up Nginx & PHP-FPM on Ubuntu 10.04

Evert Pot: MySQL 5.6 BOOL behavior when using PDO and prepared statements


Community Events

Don't see your event here?
Let us know!


community php7 security series laravel introduction list laravel5 api podcast voicesoftheelephpant extension version language release example interview library opinion framework

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework