Importing a database that’s too large for phpMyAdmin

Options for importing big SQL files: compression, splitting the file, importing table by table, and restoring through a DirectAdmin backup.

Guide2 min readLast updated
On this page
  1. 1. Compress the file
  2. 2. Allow interruption
  3. 3. Split the file
  4. 4. Export and import table by table
  5. 5. Reduce what you’re moving
  6. 6. Use a DirectAdmin backup restore
  7. Check the result
  8. Common questions

phpMyAdmin runs through PHP, so its imports are limited by upload size and execution time. For big databases, work around those limits.

1. Compress the file

A .sql file often compresses to a tenth of its size. Gzip it (.sql.gz) or zip it (.sql.zip) and import that. phpMyAdmin decompresses it on the server.

2. Allow interruption

On the Import screen, keep Allow the interruption of an import in case the script detects it is close to the PHP timeout ticked. If it stops, run the import again with the same file; phpMyAdmin offers to resume.

3. Split the file

Use a free SQL file splitter to break the dump into pieces that each fit the limit, then import them in order. Make sure the tool splits between complete statements.

4. Export and import table by table

On the old host, export the largest tables separately from the rest. Import the small tables in one file and each large table on its own.

5. Reduce what you’re moving

Large WordPress databases are often mostly logs, sessions, spam or expired transients. Clean up before exporting. Cleaning up and optimising the WordPress database

6. Use a DirectAdmin backup restore

If you’re moving from another DirectAdmin host, a full account backup restored through System Info & Files › Create/Restore Backups imports databases without phpMyAdmin’s limits. How to restore a full account backup

Check the result

Compare table counts and row counts for key tables with the original.

Prefer to follow along?

Looking for somewhere to run PHP and MySQL? Traxio’s PHP and MySQL hosting includes phpMyAdmin.

Common questions

My database is too big to import — what do I do?

Upload it compressed as a .gz or .zip, which phpMyAdmin can import directly and which is often enough on its own. If it still fails, split the file into several smaller ones and import them in order.

What does “MySQL server has gone away” mean?

The database connection was dropped mid-query, usually because the query took too long or sent too much data at once. It shows up most often when importing a large database file rather than during normal browsing.

For an import, the fix is to split the file into smaller pieces or import it compressed. For a site that shows it in normal use, the cause is usually one slow query or an unoptimised table — repairing and optimising the tables is the first thing to try.

Spotted something out of date or unclear? Tell us and we’ll fix it.

Keep going