What a database backup contains, and what it does not
A WordPress database contains your posts, pages, users, settings, comments, and most plugin data. Files alone are not a backup: if the database is lost or corrupted, a copy of wp-content will not bring the site back.
This guide covers database-only backup and restore. It does not replace a full account backup, which also protects themes, plugins, uploads, and email configuration. Use both: a full backup for disaster recovery, and a database dump you can restore quickly before a risky change.
A database dump contains the tables WordPress and its plugins use: posts, pages, metadata, users, options, comments, WooCommerce orders, and similar records.
It does not contain:
- WordPress core files, themes, and plugins.
- Images and other uploads in
wp-content/uploads. wp-config.php.- Email accounts, DNS records, or SSL certificates.
For a complete site backup, also follow How to Take a Full cPanel Backup (and Restore It).
Before you start
- Know the database name. In cPanel, open Databases then MySQL Databases (Manage My Databases in cPanel 120 and later).
- Check free space. A dump is often close to the size of the database, and a compressed dump still needs temporary space.
- Store the dump off the server. A backup on the same disk does not protect against disk failure, account suspension, or accidental deletion.
- Tell users if the site will be unavailable. Restoring replaces live data.
Important: Restoring a database overwrites the current one. If the current database contains orders, form entries, or comments created after the backup, those records will be lost. Take a fresh dump immediately before any restore, even if you believe the current database is broken.
Method 1: Back up a database from cPanel
- In cPanel, open Files then Backup.
- Under Partial Backups, find the Databases heading. Depending on the cPanel version, it may be labelled Download a Database Backup.
- Click the name of the WordPress database.
- Save the downloaded
.gzfile to a location outside the server.
The file is a compressed SQL dump. You do not need to unzip it to restore it through cPanel.
Note: cPanel's full account backup is an archival file and, according to cPanel's documentation, cannot be restored through the cPanel interface. Restoration of a full account backup is a WHM or provider operation. The partial database backup described here is the one you can restore yourself.
Method 2: Export with phpMyAdmin
- In cPanel, open Databases then phpMyAdmin.
- Select the WordPress database in the left-hand list.
- Click the Export tab.
- Choose Quick and confirm that the format is SQL.
- Click Go and save the file.
For a dump you intend to import over an existing database, use Custom instead of Quick and enable Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statement. This makes the dump remove existing tables before recreating them, which avoids "table already exists" errors during import.
Large databases: phpMyAdmin can time out or hit PHP upload and execution limits. If the export fails partway through, use WP-CLI or mysqldump instead of retrying repeatedly.
Method 3: Export with WP-CLI
On a VPS or any plan with SSH access and WP-CLI installed, run the command as the account user from the WordPress directory:
cd /home/example/public_html
wp db export wp-backup-2026-10-25.sql
To compress the dump in one step:
wp db export - | gzip > wp-backup-2026-10-25.sql.gz
WP-CLI reads the credentials from wp-config.php, so the command fails if the site's database configuration is already broken. Do not run it as root; root-owned files can break later WordPress updates.
Verify the backup before you rely on it
- Confirm the file is not empty and its size is plausible for the site.
- For a
.gzfile, test the archive withgzip -t wp-backup-2026-10-25.sql.gz. No output means the archive is intact. - Open the first part of the SQL file. It should contain a dump header and
CREATE TABLEstatements. - Compare the number of tables in the dump with the number shown in phpMyAdmin.
- If the data matters, restore the dump to a staging site and confirm that the site loads and you can log in.
A backup you have never restored is a hypothesis, not a safety net.
Restore Method A: cPanel partial restore
- In cPanel, open Files then Backup.
- Click Restore.
- Select the MySQL database restore option. The label is commonly Restore a MySQL Database Backup.
- Click Choose File and select the
.gzdump. - Click Upload and wait for the process to finish.
Do not navigate away or start another restore while the upload is running. Confirm that the restore targets the correct database before uploading; a restore into the wrong database can overwrite unrelated data.
Restore Method B: phpMyAdmin import
- In cPanel, open Databases then phpMyAdmin.
- Select the target WordPress database.
- Click the Import tab.
- Click Choose File and select the
.sqlor.sql.gzdump. - Confirm that the format is SQL.
- Click Go and wait for the success message.
If the dump does not contain DROP TABLE statements and the database already has tables, the import will fail with "table already exists". You have two safe options:
- Import into an empty database, then update
DB_NAMEinwp-config.phpif the name changed. - Drop the existing tables first, but only after taking a fresh backup of the current database.
Upload limits: a large dump may exceed upload_max_filesize or post_max_size. If your plan provides Software then MultiPHP INI Editor, you may be able to raise these limits for the account. Otherwise use WP-CLI or ask support to import the dump.
Restore Method C: WP-CLI import
cd /home/example/public_html
wp db import wp-backup-2026-10-25.sql
For a compressed dump:
gunzip -c wp-backup-2026-10-25.sql.gz | wp db import -
wp db import does not create the database. The database and user must already exist and be reachable through wp-config.php.
After the restore
- Clear page cache, object cache, and any CDN cache. Cached HTML can hide a successful restore or keep serving stale content.
- Load the home page and several inner pages.
- Log in at
/wp-admin. - If inner pages return 404 errors, open Settings then Permalinks and click Save Changes to rebuild rewrite rules.
- Run
wp db checkif WP-CLI is available. - Confirm that recent content, orders, or form entries are present, or knowingly accept the rollback.
- Delete the dump from the server once the restore is verified.
If the restore fails
- "Table already exists": the dump lacks drop statements, or the target database was not empty. Use a dump with
DROP TABLEstatements or import into an empty database. - Upload or execution timeout: the dump is too large for the web interface. Use WP-CLI or ask support.
- Access denied: the database credentials are wrong or the user lacks privileges. See "How to Find, Verify, and Reset WordPress Database Credentials in cPanel".
- Partial import: do not retry blindly on the production database. Restore the fresh pre-restore dump, then investigate the failed statement.
Recovery and rollback
Before any restore, export the current database and keep it until the restored site has been verified. If the restore fails or restores the wrong data, import that pre-restore dump to return to the previous state. If files were also changed, restore them from the full account backup or your own file backup.
Security considerations
Database dumps contain password hashes, email addresses, order records, and other personal data. Treat them as sensitive:
- Store dumps off the server and encrypt them at rest.
- Never leave a
.sqlor.sql.gzfile inpublic_htmlor any web-accessible directory. - Delete old dumps when they are no longer needed.
- Transfer dumps over SFTP or another encrypted channel, not email.
- Restrict file permissions so other users on the server cannot read them.
Related articles
- How to Take a Full cPanel Backup (and Restore It)
- cPanel Tutorial for Beginners
- How to Fix "Error Establishing a Database Connection" in WordPress
- How to Find, Verify, and Reset WordPress Database Credentials in cPanel
Contact SysopHost support if the dump is too large for cPanel or phpMyAdmin to restore, if a restore times out repeatedly, or if the database was deleted and you need to check whether a provider-side backup is available for your plan. Include the database name, the dump size, the exact error, and the steps you have already completed.