Importing a database restores data from a backup file (.sql, .gz, or .zip) into an existing MySQL database. This is commonly used when migrating a website, restoring from a backup, or setting up a staging environment. This guide covers importing via phpMyAdmin in cPanel.
Before You Begin
- Ensure the target database already exists. If not, create one first in cPanel under Databases → MySQL Databases.
- Ensure a database user is assigned to the database with All Privileges.
- Keep your .sql backup file ready on your computer.
Importing a Database via phpMyAdmin
- Log in to your cPanel account.
- Scroll to the Databases section and click phpMyAdmin.
- In the left sidebar, click the + icon to expand the list of databases.
- Click on the database into which you want to import data.
- Click the Import tab at the top of the page.
- Under File to import, click Browse (or drag and drop your file).
- Select the
.sqlfile from your computer. - Under Format, ensure SQL is selected.
- Click Go at the bottom of the page.
- phpMyAdmin will process the import. A success message will appear when complete.
Alternative: Using the cPanel Backup Tool
- In cPanel, go to Files → Backup.
- Scroll to Restore a MySQL Database Backup.
- Click Choose File and select your backup file.
- Click Upload.
This method handles database prefixes automatically and is recommended for standard restores.
Import File Size Limits
- phpMyAdmin typically has an upload limit (often 50 MB or 128 MB, depending on server configuration).
- If your database file exceeds this limit, you may need to:
- Split the SQL file into smaller chunks.
- Contact your hosting provider to temporarily increase the upload limit.
- Import via SSH using the
mysqlcommand line.
Important Notes
- Importing a database will overwrite existing tables with the same names in the target database.
- Always back up the existing database before importing, in case you need to revert.
- Ensure the SQL file was exported with the correct database prefix (cPanel adds a prefix like
username_to database names). - Large imports may take several minutes. Do not close the browser window during the process.
Troubleshooting
"You probably tried to upload a file that is too large":
- Your file exceeds the server upload limit. Contact your hosting provider or use SSH to import.
"SQL query error" or import fails partway:
- The SQL file may contain errors or be incompatible with your MySQL version.
- Check if the file was exported from a different MySQL version and may contain unsupported syntax.
- Try importing via the cPanel Backup tool instead.
"No database selected" error:
- Make sure you clicked on the database name in the left sidebar before clicking the Import tab.
Import completes but tables appear empty:
- Check that you imported into the correct database.
- Verify the SQL file contains actual data (not just the structure).