Skip to content
th3khan

case 01

import-sql

A single PHP file that imports .sql dumps of hundreds of megabytes where phpMyAdmin gives up. Public on GitHub, with steady organic traffic.

A .sql dump drawn as a slab of unreadable statements, streamed through an amber conduit in separated chunks into a database cylinder, with a progress bar partway through.

The problem

Importing a dump of a few hundred megabytes through phpMyAdmin fails on upload limit, execution time or memory — and it almost never says which of the three.

The decision

A single dependency-free PHP file that streams the dump and executes statement by statement, with live progress and a server-path route that sidesteps the upload limit.

The outcome

A public tool that still gets organic traffic years after it shipped.

It was born in September 2023 from a problem of my own: restoring a real database on shared hosting where phpMyAdmin never made it to the end. The environment where this problem exists — no SSH, no mysql CLI, no touching php.ini — is exactly the environment where you cannot install anything. That is why the tool is a single PHP file: copy it to the server, open it in the browser, delete it when done.

How it works

  • It never loads the file into memory. It walks the dump line by line through a file handle, accumulates each statement up to its closing ; and executes it on the spot. The dump size stops being the limit; tested with ~200 MB dumps.
  • Progress is painted by the HTML stream itself. Every thousand lines it emits a fragment that updates the bar and flushes the output buffer. No AJAX, no polling, no framework.
  • A SQL error does not abort the import. It is reported with its line number, the next statement runs, and the final tally says how many executed and how many failed.
  • The upload-limit escape hatch: when the .sql exceeds what the hosting allows over POST, upload it over FTP and hand the script the local path. That second route sidesteps every upload limit at once.

Two lives in the history

The 2023 version was 262 lines solving that day’s problem, with a 10-minute cap and no progress bar. In May 2025 I rewrote it whole: an interface with real progress, dual input methods, per-statement error tolerance and no execution time limit. The git history tells both eras as they happened.

It is the piece of mine that most people have used without knowing who wrote it.