Skip to main content

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​

FlagDescription
--yesSkip the confirmation prompt (required for scripts)
--dbuser=VALUEOverride DB user
--dbpass=VALUEOverride 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​

CommandDatabase containerTablesUse when
wp db drop --yes❌ Deleted❌ DeletedFull teardown — you'll recreate the DB too
wp db reset --yes✅ Preserved❌ DeletedClean 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​

  1. Always export before resetting — wp db export takes seconds and saves you from irreversible data loss.
  2. Use --yes only in non-interactive environments (CI, Docker, scripts) — never blindly in manual workflows.
  3. Prefer wp site empty to wipe a single multisite sub-site instead of resetting the entire DB.
  4. Combine with wp core install for a true clean WordPress setup from scratch.

Troubleshooting​

ProblemCauseFix
Access deniedDB user lacks DROP privilegeUse a more privileged user via --dbuser
Reset fails mid-wayTables locked by another processKill competing queries; retry
Site still broken after reset + importURLs not updatedRun 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​