Importing & Exporting Databases
Exporting saves a copy of your database as a SQL file you can keep as a backup or move to another server. Importing loads that file back in. Both are easy in phpMyAdmin, with a couple of extra options for large databases.
Exporting with phpMyAdmin
- Open phpMyAdmin from cPanel.
- In the left pane, click the database you want to export.
- Click the Export tab at the top.
- Choose an export method (see below), leave the format set to SQL, and click Go.
- Your browser downloads a
.sqlfile containing the complete database.
Quick vs Custom
- Quick — Exports everything with sensible defaults. This is all most people need.
- Custom — Lets you pick specific tables, add
DROP TABLEstatements, and choose compression. Select gzipped under compression to download a smaller.sql.gzfile, which is handy for large databases.
Importing with phpMyAdmin
- Open phpMyAdmin and select the target database in the left pane.
- Click the Import tab.
- Click Choose File and select your
.sqlor.sql.gzfile. - Leave the format as SQL and click Go.
- phpMyAdmin loads the file and reports success when it finishes.
Handling Large Databases
When a database is too big to import through the browser, you have a few options:
- Compress it — Export with gzip compression; a compressed
.sql.gzis often small enough to upload. - Split the dump — Break a very large SQL file into smaller files and import them one at a time.
- Import over SSH — Upload the file and load it with the
mysqlcommand line client (see below). - Ask us — Open a support ticket and we can import a large dump for you server-side.
Importing over SSH
If you have SSH access, upload the .sql file to your account, then run the mysql client. The -p flag prompts for the database user's password:
mysql -p cpuser_dbname < backup.sql
Replace cpuser_dbname with your full prefixed database name and backup.sql with your file. If the file is gzipped, decompress it on the fly:
gunzip < backup.sql.gz | mysql -p cpuser_dbname
Downloading a Database from cPanel Backup
You do not have to open phpMyAdmin just to grab a copy of a database. The cPanel Backup tool offers a one-click download:
- Log into cPanel.
- In the Files section, click Backup.
- Under Download a MySQL Database Backup, click the name of the database.
- A
.sql.gzfile downloads to your computer.
You can restore this same file from the Backup page later — see Backups & Restore for the full process.