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 DatabasesMySQL 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

  1. Log in to your cPanel account.
  2. Scroll to the Databases section and click phpMyAdmin.
  3. In the left sidebar, click the + icon to expand the list of databases.
  4. Click on the database into which you want to import data.
  5. Click the Import tab at the top of the page.
  6. Under File to import, click Browse (or drag and drop your file).
  7. Select the .sql file from your computer.
  8. Under Format, ensure SQL is selected.
  9. Click Go at the bottom of the page.
  10. phpMyAdmin will process the import. A success message will appear when complete.

Alternative: Using the cPanel Backup Tool

  1. In cPanel, go to FilesBackup.
  2. Scroll to Restore a MySQL Database Backup.
  3. Click Choose File and select your backup file.
  4. 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 mysql command 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).
Was this answer helpful? 0 Users Found This Useful (0 Votes)