If you try to import a large .sql file into phpMyAdmin and it fails partway through, times out, or shows an error before it even starts, the cause is almost always the same: phpMyAdmin's upload size and execution time limits are set by your hosting account's PHP configuration, not by phpMyAdmin itself. Most accounts default to a fairly small limit, often around 50MB, which a full database export can easily exceed.
There are a few reliable ways to get a large database imported. Try them in order, starting with the simplest.
Option 1: Compress the File Before Importing
A .sql file compresses very well, often shrinking by 80-90%. phpMyAdmin can read compressed files directly, so this alone solves the problem for many medium-sized databases.
- If you haven't already exported the database, do so first (see the related article below for the basic export steps).
- On your computer, compress the .sql file into a .zip or .gz archive.
- In phpMyAdmin, open the database and go to the Import tab.
- Choose your compressed file. phpMyAdmin detects the format automatically and decompresses it during import, so you don't need to unzip it first.
Option 2: Raise the Upload and Execution Limits
If the compressed file is still too large, you can raise the PHP limits that control uploads for your domain.
In cPanel
- Log in to cPanel and open MultiPHP INI Editor.
- Select your domain from the dropdown, then switch to Editor Mode.
- Increase the values for upload_max_filesize, post_max_size, and max_execution_time.
- Click Save and try the import again.
In DirectAdmin
- Log in to DirectAdmin and open Select PHP Version (sometimes listed under Advanced Features).
- Enable the custom php.ini or additional directives option for your PHP version.
- Add or edit the lines for upload_max_filesize, post_max_size, and max_execution_time, then save.
- Reload PHP if you're prompted to, then retry the import.
Even a raised limit is still a limit. If your database is several hundred megabytes or more, the command-line method below is faster and more reliable than pushing phpMyAdmin's limits higher and higher.
Option 3: Split the File Into Smaller Chunks
For very large exports, you can split the .sql file into several smaller files and import them one at a time. This works with a plain text editor for smaller splits, or an SQL-splitting utility for very large files, as long as you avoid cutting a file in the middle of a single statement (a split should only happen between complete SQL lines).
Option 4: Import via SSH (Fastest for Large Databases)
If SSH access is enabled on your hosting account, this is the most reliable option since it has no upload size limit at all.
- Upload your .sql (or .sql.gz) file to your hosting account using File Manager or FTP.
- Connect to your hosting account over SSH.
- Run: mysql -u username -p database_name < filename.sql, then enter your database password when prompted.
- For a compressed file, run gunzip -c filename.sql.gz | mysql -u username -p database_name instead, which decompresses and imports in one step.
Importing will overwrite any existing tables with the same names in the destination database. If the database already has data you need, back it up first.
For the basic export and import steps, see How to Import and Export a MySQL Database Using phpMyAdmin.