WP-CLI Database: export first, –dry-run second

The database has no Undo. So every database block starts with an export.

The classic trap: an AI assistant suggests one quick SQL query to change the domain. You press Enter. Plugin settings are a serialized array: s:24 says the string is 24 characters, but the new URL has 31. unserialize() fails, WordPress sees false. Settings gone. No error.

The right block:

  1. wp db export before-migration.sql
  2. wp search-replace ‘http://old.test’ ‘https://new-domain.com’ –dry-run
  3. Read it. Type PHP = serialized data, lengths get recounted.
  4. wp search-replace ‘http://old.test’ ‘https://new-domain.com’
  5. Something wrong? wp db import before-migration.sql

AI can type the command. Only you press Enter.

Practice Cases: real workflows built with WP-CLI commands. We built a WP-CLI practice terminal. Break nothing.

Go deeper