wp core update-db
Apply any pending WordPress database schema upgrades after updating WordPress core files. This is the second step in a core update — files first, then database.
What It Does
After wp core update downloads and installs new core files, some WordPress versions require database table schema changes. wp core update-db runs all pending dbDelta() upgrade routines, updates the db_version in wp_options, and reports what was changed.
Skipping this step can cause subtle bugs — undefined database columns, deprecated data structures, or admin notices like "Database update required."
Syntax
wp core update-db [--network] [--dry-run]
Options & Flags
| Flag | Description |
|---|---|
--network | Run update on all sites in a multisite network |
--dry-run | Show what would be updated without making changes |
Basic Usage
Run database update (standard)
wp core update-db
Preview changes before applying
wp core update-db --dry-run
Update all sites in a multisite network
wp core update-db --network
Expected Output
When changes are needed:
Success: WordPress database upgraded successfully from db version 56657 to 57155.
When already up to date:
Success: WordPress database already at latest db version 57155.
The Core Update Workflow
Always run wp core update-db immediately after wp core update:
# Step 1: Update core files
wp core update
# Step 2: Update the database schema
wp core update-db
# Step 3: Verify (optional)
wp core verify-checksums
Running WordPress with outdated DB schema causes undefined behavior. Always run wp core update-db as part of your update workflow.
Real-World Scenarios
Scenario 1: Standard maintenance update
#!/bin/bash
echo "Starting WordPress maintenance update..."
# Backup first
wp db export backup_before_update_$(date +%Y%m%d).sql
# Enable maintenance mode
wp maintenance-mode activate
# Update core
wp core update
# Update database schema
wp core update-db
# Update plugins and themes
wp plugin update --all
wp theme update --all
# Disable maintenance mode
wp maintenance-mode deactivate
echo "Update complete: $(wp core version)"
Scenario 2: Multisite network database update
# Update all sites in the network
wp core update-db --network
# Verify
wp site list --format=table
Scenario 3: Dry run before production update
# Preview what will change
wp core update-db --dry-run
# If looks good, apply
wp core update-db
Scenario 4: CI/CD pipeline database step
# After deploying new core files
wp core update-db --quiet && echo "DB schema up to date" || echo "DB update failed"
Best Practices
- Always pair with
wp core update— never skip the DB step. - Take a DB backup first with
wp db exportbefore any update. - Use
--dry-runin production to preview changes before applying. - Use
--networkon multisite — each sub-site may need its own DB upgrade. - Use with maintenance mode on live sites to prevent data inconsistency during upgrade.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| Admin shows "Database update required" banner | update-db not run after core update | Run wp core update-db immediately |
| Command reports errors | Corrupt tables or missing columns | Run wp db repair then retry |
| Multisite: some sites not updated | Sites skipped in --network run | Run again or target specific sites with --url |
| Silent failure | Permissions issue | Check MySQL user has ALTER TABLE privileges |
Quick Reference
wp core update-db # Apply pending schema upgrades
wp core update-db --dry-run # Preview without applying
wp core update-db --network # All sites in multisite
wp db export backup.sql # Backup before updating
Next Steps
wp core update— update core files first.wp core verify-checksums— verify file integrity after update.wp db export— back up the database before updating.