Importing Large MySQL Dumps with BigDump

Staggered imports on limited hosts

Get oversized MySQL dumps imported when phpMyAdmin gives up.

Archived Published 1 Jun 2014 at 09:00

This is an older piece, kept as a record. It reflects the tools and versions of its time — check the dates before relying on any specifics.

It can be a pain working with large databases, especially on servers with limited resources or over a slow connection. Tools such as phpMyAdmin sometimes run into irritating issues. Other options are available for importing large or complex data dumps.

P.I.T.A.

I often find myself hitting a brick wall with large MySQL imports, running into issues getting them uploaded to my local (or remote) development servers. While not a massive obstacle, chances are on any given web project of a significant scale, database import issues will rear their head.

If you’re struggling with getting a particular MySQL export file imported to your database, I recommend you check out BigDump — staggered dump importer which breaks up any given import into chunks and processes them one at a time.

Heads up BigDump is effectively abandonware — the last release predates PHP 8 (around 2014) and it isn’t maintained. On a modern stack the reliable default is the MySQL CLI, which has no upload limit or execution timeout to fight:

mysql -u username -p mydatabase < dump.sql
# or gzipped:
gunzip -c dump.sql.gz | mysql -u username -p mydatabase

On a WordPress site, WP-CLI wraps that up: wp db import dump.sql. Both stream the file server-side, so the multi-gigabyte imports that used to choke phpMyAdmin just work. Keep BigDump in mind only as a last-resort, no-shell fallback on restricted shared hosting.

Bigdump

Usage is pretty straightforward, download the archived zip file from the link above and extract it to a suitable location on your web server.

Open up bigdump.php with the code editor of your choice, and edit the following lines to match your database config.

$db_server   = 'localhost';
$db_name     = 'mydatabase';
$db_username = 'username';
$db_password = 'secr3t!'; // don't use this as your password, obviously

Bigdump contains a whole heap of other handy configuration options that may come in useful if you do run into further issues during usage.

The one I’ve encountered most often, and which seem to help diagnosing most of the common issues are:

$linespersession    = 3000;

Adjust the $linespersession variable downwards if you still experience timeout issues.

$delaypersession    = 0;

If you find that the immport is running into problems with MySQL’s max_requests setting, add some more milliseconds to the $delaypersession variable

$max_query_lines = 300;

Handy if you have some particularly large queries to process. I’ve found that notching $max_query_lines up to 3000 or even 30000 has no major impact, and seems to solve most of the issues I’ve encountered

If you’re still running into problems, check out Bigdump’s faq page.

All-in-all, it’s one of the most useful database tools I’ve found, and out-performs even some of the more professional offerings out there. Definintely worth a try if you’re experiencing MySQL headaches.

Vital note: Delete this from your server once you’re done. It’s a massive no-no to leave something like this sitting around on a production (or even a development) server.

All articles

Let's talk.

I help content-rich organisations understand their data and pull it back into one place. Tell me what specific problems you're having and I'll be happy to talk solutions with you.