Backups & maintenance · Guide
How to Back Up the WordPress Database

Short answer
To back up the WordPress database, export it to a .sql file with phpMyAdmin, WP-CLI, or a backup plugin. In phpMyAdmin, select the database, click Export, choose Quick and SQL format, and save the file with your file backup, or in WP-CLI, run wp db export. Store the export off the server and test the restore on staging.
Key takeaways
- The database holds every post, comment, user, and setting, and it cannot be downloaded again if lost.
- Downloading the WordPress folder does not back up the database, which lives in MySQL or MariaDB.
- In phpMyAdmin, use Quick export with SQL format, or Custom with Add DROP TABLE and IF NOT EXISTS.
- wp db export runs mysqldump with the credentials from wp-config.php and names the file with the date.
- Store exports outside the web root, because they hold user emails and password hashes.
- Restore the files first and the database second, and test the import on staging.
What does the WordPress database hold?
The WordPress database holds every post, every comment, every user, and every setting on your site.
WordPress.org states it plainly: if your database gets erased or corrupted, you stand to lose everything you have written, as its backup guide explains (checked November 2026). The database also holds your menus, widgets, theme settings, plugin settings, and, on a store, your orders and products.
The files hold the other half: WordPress core, themes, plugins, and uploads. The two halves live in different places. Your files sit in the WordPress folder on the web server.
Your database sits in a separate MySQL or MariaDB system, which is why downloading your folder does not back it up.
Why back up the database on its own?
Back up the database on its own because a file backup does not include it, and the database is the part you cannot download again.
WordPress core, themes, and plugins can be downloaded again from their sources. Your posts, comments, users, and settings exist only in your database. Lose the database and you lose the content itself, even if every file survives.
The database also changes faster than the files. A new comment, order, or settings change lands in the database at once, while the files may not change for days. That is why the WordPress backup guide says to back up the database regularly and always before an upgrade (checked November 2026).
A file backup from last week plus a database backup from today is a working site. A file backup from today plus no database backup is an empty shell.
How do you export with phpMyAdmin?
Open phpMyAdmin from your hosting panel, select your database, click Export, choose Quick and SQL format, and save the file.
First find your database name in wp-config.php, on the line that defines DB_NAME. The same file holds the database user and password you need to log in. Open phpMyAdmin from your hosting panel, through cPanel, Plesk, or your host's own panel, and select the database that matches DB_NAME.
Then click Export. The WordPress backup guide describes two methods, Quick and Custom (checked November 2026). Quick is enough for most sites.
If you choose Custom, select all the tables, check Save output to a file, pick SQL as the format, check Add DROP TABLE and IF NOT EXISTS, then click Go. Add DROP TABLE lets the export overwrite an existing database on restore, and IF NOT EXISTS prevents errors when tables already exist.
The export downloads as a .sql file, or a compressed .gz or .bz2 file if you choose compression. Store it in the same dated folder as your file backup so the two halves stay together. The Learn WordPress lesson on backups walks through the same steps with screenshots (checked November 2026).
How do you export with WP-CLI?
Run wp db export from the server, and it writes the database to a .sql file using the credentials in wp-config.php.
WP-CLI is the command-line tool for WordPress. Its wp db export command runs the mysqldump utility with the DB_HOST, DB_NAME, DB_USER, and DB_PASSWORD values from wp-config.php, as the WP-CLI command reference explains (checked November 2026). You never type the database password on the command line.
If you give no file name, WP-CLI names the file {dbname}-{Y-m-d}-{random-hash}.sql and writes it into the current folder. Give it a name to keep things tidy, for example wp db export backup-2026-11-21.sql. You can also export only some tables with --tables, or leave tables out with --exclude_tables, for example to skip a large log table.
Store exports outside the web root, and delete them when they are no longer needed, as the WordPress hosting handbook advises. A database export sitting in a public folder can be downloaded by anyone who finds the address, and it holds user emails and password hashes. WP-CLI suits large databases and repeat exports, since a browser export can time out on a big site.
| Method | What you need | Best for |
|---|---|---|
| phpMyAdmin Quick export | Hosting panel access | Most sites, one-off exports |
| phpMyAdmin Custom export | Hosting panel access | Picking tables or adding options |
WP-CLI wp db export | SSH access, WP-CLI installed | Large databases, repeat exports |
| Backup plugin | Plugin plus storage account | Scheduled exports on autopilot |
| Host backup tool | Hosting panel access | A second copy, not your only copy |
How do you back up the database with a plugin?
Install a backup plugin, set a separate schedule for the database, and point it at remote storage so the export leaves the server.
Most backup plugins let you set separate schedules for files and database backups. Set the database to back up more often than the files, since it changes faster. A store that takes orders daily should export its database daily at least.
WordPress.org suggests weekly backups for smaller sites and daily backups for high-activity sites, as its backup guide states (checked November 2026).
UpdraftPlus is the most widely installed backup plugin on WordPress.org. Its free version schedules database backups, restores from the dashboard, and sends copies to Google Drive, Dropbox, Amazon S3, FTP, or email. Jetpack VaultPress Backup takes a different route: it runs a full backup at least once a day and adds real-time backups after each change, storing everything on Jetpack servers, as the Jetpack backup documentation explains (checked November 2026).
A plugin backup is only as good as its storage. Confirm the export actually arrived in your remote storage, and confirm the schedule still runs after plugin updates. A plugin that stores exports in wp-content and never sends them elsewhere leaves your database on the same server as your site.
How do you restore a database backup?
Restore the files first, then import the database, and check wp-config.php if the database credentials changed.
That order comes from the WordPress backup guide: back up the database first and the files second, but restore the files first and then import the database (checked November 2026). If you moved hosts, update wp-config.php with the new database name, user, and password before you import.
With phpMyAdmin, open the empty database, click Import, choose the .sql file, and run it. With WP-CLI, run wp db import with the file name. The import drops and rebuilds the tables when the export includes DROP TABLE statements, which is why the export options in the section above matter.
After the import, log in to the admin and check that recent posts, users, and settings are all there. Open the home page and a post. If the site shows old content, the import may have gone into the wrong database, so check DB_NAME in wp-config.php first.
For the full restore flow, see the guide to restoring a WordPress site from backup.
To check the database is healthy before you export, read the guide to optimizing the WordPress database.
How often should you export, and how many copies do you keep?
Export weekly for a small site and daily for a busy one, and keep at least 3 to 5 recent copies in different places.
That pace comes from the WordPress backup guide, which suggests weekly backups for smaller sites and daily backups for high-activity sites, and keeping at least 3 to 5 recent backups stored in different locations (checked November 2026). A store should export daily, since each day of orders lives only in the database.
Treat each export as part of a backup set with its matching file backup. Make the database export first and the files second, so the two halves describe the same moment. Store the set in more than one place: one copy on the server, one in cloud storage, and one downloaded to your own computer.
A single export on the same server dies with the server.
Keep one copy of the set off-site. CISA recommends three copies on two kinds of storage with one copy off-site, as its backup guidance states (checked November 2026).
Also export before every core, plugin, or theme update, and before any move to a new host. Updates rarely break a database, but when they do, the export from an hour ago is the way back. The guide to how often to back up WordPress covers the rhythm in detail.
What goes wrong with database backups?
The most common failures are exports that time out, exports stored where anyone can download them, and exports nobody has ever restored.
Large databases can time out in a browser export. If phpMyAdmin stops partway, switch to WP-CLI or your host's backup tool, which do not depend on a browser session. Compression helps too: a .gz export is smaller and faster to download than a plain .sql file.
Storing exports in a public folder is a security problem. Database exports hold user emails and password hashes, so keep them outside the web root or in remote storage, never in a folder a visitor can open. Delete old exports you no longer need.
The last failure is the quietest: an export that has never been restored. Import it on a staging site and confirm the posts, users, and settings come back. Jetpack's own documentation notes that it skips database tables with no unique key or primary key, and tables that do not look like WordPress tables, as its backup documentation explains (checked November 2026).
A plugin export can miss a table for the same reason, so check the table list in the export before you trust it.
The guide to testing a WordPress backup walks through the check.
The comparison of cPanel and plugin backups covers the two routes side by side.
Frequently asked questions
Does backing up my files also back up the database?
No. The database lives in a separate MySQL or MariaDB system, outside your WordPress folder. Downloading the folder copies the files only. WordPress.org says you need both parts to fully restore a typical site, so export the database as well.
Should I use Quick or Custom export in phpMyAdmin?
Use Quick export for most sites. It exports all tables as SQL in one click. Use Custom when you need to pick tables, add DROP TABLE and IF NOT EXISTS options, or compress a large database. Both produce a .sql file you can import to restore.
Is wp db export safe to run?
Yes. WP-CLI reads the database credentials from wp-config.php and runs the mysqldump utility, so you never type the password on the command line. Store the export outside the web root and delete it when you no longer need it.
My database import finished but nothing changed. What went wrong?
Check that you imported into the right database by matching DB_NAME in wp-config.php, and that you restored the files first and the database second. An export that lacks DROP TABLE statements will not overwrite existing tables, so check the export options you used.
How often should I export the database?
It depends on how often the site changes. WordPress.org suggests weekly exports for smaller sites and daily exports for high-activity sites. A store that takes orders daily should export daily, and always before an update or a move.
Sources
- Backups: Advanced Administration Handbook WordPress Developer Resources
- wp db export: WP-CLI Command WordPress Developer Resources
- Backing Up Your WordPress Site Learn WordPress
- Back up your site with Jetpack VaultPress Backup Jetpack
- Back Up Government Data CISA
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.


