UnderHost
Knowledgebase Docs

Database import and export: migrate your data

Export database via mysqldump or phpMyAdmin, import to new server, handle large exports and compression.

On this page

Exporting and importing databases is essential for s, backups, and data transfers between servers. MySQL provides several methods from command-line to phpMyAdmin.

Export database

Via command line (mysqldump)

mysqldump -u username -p databasename > backup.sql
# Creates backup.sql file

Via phpMyAdmin

  1. Log in to phpMyAdmin (cPanel)
  2. Select your database
  3. Click Export tab
  4. Choose Quick or Custom export
  5. Select SQL format
  6. Click Go to download

Import database

Via command line

mysql -u username -p databasename < backup.sql

Via phpMyAdmin

  1. Create empty database on new server
  2. Log in to phpMyAdmin
  3. Select the empty database
  4. Click Import tab
  5. Upload your backup.sql file
  6. Click Go

Large database handling

Problem: phpMyAdmin upload limits often block large files (default 2-8MB).

Solution: Use command line for large exports:

mysqldump -u user -p --single-transaction mydb > backup.sql
# --single-transaction avoids locking

Compression options

Compress export to reduce file size:

mysqldump -u user -p mydb | gzip > backup.sql.gz
# Decompress before importing
gunzip backup.sql.gz
Always verify imported data

After importing, verify that tables exist and contain data: SHOW TABLES; and SELECT COUNT(*) FROM table;

Related: Database backups | Website

Was this article helpful?

Need hosting for database-backed apps?

Run WordPress, CMS, PHP apps, and MySQL/MariaDB workloads on UnderHost hosting, VPS, or managed servers.

Related articles

Back to Database