If you try to export a large MySQL database through phpMyAdmin and the page times out, shows a blank screen, or produces a truncated file, it is usually because the web server's script execution time or memory limit runs out before phpMyAdmin can finish building the file. The command-line mysqldump tool is not limited the same way, so it is the more reliable option once a database grows past a few hundred megabytes.
Why phpMyAdmin Struggles With Large Exports
phpMyAdmin runs inside your web browser's request to the server, which is capped by PHP's execution time and memory settings. A small database exports in seconds, but a database with millions of rows or large tables can take longer than the server allows, so the export fails partway through.
mysqldump runs directly on the server through a terminal session instead of through a web page, so it is not subject to those same browser-request limits.
Before You Start
- You will need SSH access enabled on your hosting account. If you have not set this up yet, see How to Enable and Use SSH Access on Your Hosting Account.
- You will need your database name, database username, and that user's password. You can find these in your control panel's MySQL Databases section.
- Enough free disk space in your hosting account to hold the exported file, at least as large as the database itself.
If you would rather not use SSH at all, you can instead enable remote access to your database and run the export from a MySQL client on your own computer. See How to Enable Remote MySQL Access to Your Database.
Exporting Your Database With mysqldump
Connect to your hosting account over SSH using a terminal application, or your control panel's built-in terminal. The commands below are identical either way, since mysqldump is not tied to one control panel - the steps are the same whether you are on cPanel or DirectAdmin.
- Log in to your server over SSH using your hosting username and password, or an SSH key.
- Run the following command, replacing the placeholders with your own database name and username:
mysqldump -u your_db_username -p your_database_name > backup.sql - Press Enter, then type the database user's password when prompted. Nothing will appear on screen as you type. That is normal.
- Wait for the command prompt to return. Depending on the database size, this can take anywhere from a few seconds to several minutes.
- Run
ls -lh backup.sqlto confirm the file was created and check its size.
For very large databases, compress the output as it is created to save space and time:mysqldump -u your_db_username -p your_database_name | gzip > backup.sql.gz. You will need to decompress it withgunzipbefore importing it anywhere else.
Downloading the Backup File to Your Computer
Once the export finishes, the file sits in your hosting account's file system, not on your own computer yet. Download it using either:
- Your control panel's File Manager, by navigating to the file and choosing Download.
- An FTP or SFTP client, connecting with the same account you normally use for file transfers.
Once you have confirmed the file downloaded correctly and you no longer need a copy on the server, delete it from your hosting account to free up disk space.
If the Export Still Fails
If mysqldump also fails, or you do not have SSH access and cannot get it enabled, contact support and ask about a server-side export, or try exporting one table at a time from phpMyAdmin instead of the whole database at once. Exporting table by table uses far less memory per export and is a reasonable workaround when SSH is not an option.