wp db reset
Overview
Remove all WordPress database tables without dropping the database itself. The database remains — just completely empty. Use before importing a fresh dump or reinstalling WordPress cleanly.
What It Does
wp db reset drops every table listed in wp db tables, then recreates the empty database. Unlike wp db drop, the database container itself is preserved. This avoids needing re-grant permissions after the operation.
Syntax
wp db reset [--yes] [--dbuser=<value>] [--dbpass=<value>]
Options & Flags
| Flag | Description |
|---|---|
--yes | Skip the confirmation prompt (required for scripts) |
--dbuser=VALUE | Override DB user |
--dbpass=VALUE | Override DB password |
Basic Usage
Interactive reset (prompts for confirmation)
wp db reset
Are you sure you want to reset the 'wpdb' database? [y/n] y
Success: Database reset.
Non-interactive (scripts)
wp db reset --yes
All data is permanently deleted
wp db reset drops every table and all data. This cannot be undone. Always export first.
How It Differs from Drop
| Command | Database container | Tables | Use when |
|---|---|---|---|
wp db drop --yes | ❌ Deleted | ❌ Deleted | Full teardown — you'll recreate the DB too |
wp db reset --yes | ✅ Preserved | ❌ Deleted | Clean wipe without needing to recreate the DB |
Real-World Scenarios
Scenario 1: Clean slate before fresh import
# Export current state as safety net
wp db export "pre_reset_$(date +%Y%m%d%H%M).sql"
# Wipe and import fresh dump
wp db reset --yes
wp db import fresh_dump.sql
wp search-replace 'https://production.com' 'https://staging.com'
wp cache flush
Scenario 2: Reinstall WordPress cleanly
wp db reset --yes
wp core install \
--url="http://localhost" \
--title="Fresh Install" \
--admin_user=admin \
--admin_password=admin123 \
--admin_email=admin@localhost \
--skip-email
Scenario 3: CI/CD test teardown and setup
# Before each test run — reset to a known clean state
wp db reset --yes
wp db import ./tests/fixtures/base.sql
Scenario 4: Reset a multisite sub-site
wp site empty 2 --yes # Empty a specific blog's tables
# OR reset the entire network DB
wp db reset --yes
Best Practices
- Always export before resetting —
wp db exporttakes seconds and saves you from irreversible data loss. - Use
--yesonly in non-interactive environments (CI, Docker, scripts) — never blindly in manual workflows. - Prefer
wp site emptyto wipe a single multisite sub-site instead of resetting the entire DB. - Combine with
wp core installfor a true clean WordPress setup from scratch.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
Access denied | DB user lacks DROP privilege | Use a more privileged user via --dbuser |
| Reset fails mid-way | Tables locked by another process | Kill competing queries; retry |
| Site still broken after reset + import | URLs not updated | Run wp search-replace |
Quick Reference
wp db reset # Interactive
wp db reset --yes # Non-interactive
wp db export backup.sql && wp db reset --yes # Safe reset
wp db reset --yes && wp db import dump.sql # Wipe and restore
Next Steps
wp db import— import a dump after resetting.wp db export— always export before resetting.wp core install— reinstall WordPress after a reset.