Skip to content

Tutorials cPanel Beginner1 min read

How to Import and Export a MySQL Database with phpMyAdmin

Back up a database to a .sql file and restore it with phpMyAdmin in cPanel, plus what to do when the import is too large or times out.

By ZSOLNET Editorial Team Updated

Key takeaways

  • Export creates a .sql file you can keep as a backup or move to another server.
  • Import into an empty database to avoid duplicate-table errors.
  • Large databases import more reliably over SSH.

Export a database

  1. In cPanel, open Databases → phpMyAdmin.
  2. Select the database in the left sidebar.
  3. Click the Export tab.
  4. Choose Quick and format SQL for a complete export. Choose Custom if you want compression or to add DROP TABLE statements.
  5. Click Export and save the .sql file.

Import a database

  1. Create an empty database and user in MySQL Databases if you don’t have one, and give the user all privileges on it.
  2. In phpMyAdmin, select the empty database.
  3. Click Import, choose your .sql or .sql.gz file and click Import.
  4. A green success message lists how many queries ran.

Large databases: use SSH

# export
mysqldump -u dbuser -p dbname | gzip > dbname.sql.gz
# import
gunzip < dbname.sql.gz | mysql -u dbuser -p dbname

After moving a WordPress database

Update DB_NAME, DB_USER and DB_PASSWORD in wp-config.php. If the domain changed too, run a search-and-replace on the old URL — see the guide to moving WordPress to a new domain.

Frequently asked questions

My import fails with a size error. What can I do?

Compress the file as .sql.gz (phpMyAdmin accepts it), raise the PHP upload limit, or import over SSH with the mysql command, which has no upload limit.

I get 'Table already exists'.

The target database isn't empty. Drop the existing tables first (after making sure you don't need them), or tick 'Add DROP TABLE' when exporting.

Share X LinkedIn Facebook

Log in to your account

Manage your domains, hosting and invoices in one place.

Secure connection straight to the ZSOLNET client area.

No account yet?