READ-ONLY PACKAGE PREVIEW

wp-wpcli-and-ops/references/search-replace.md

Version 34da134e184e.bb1 · GPL-2.0-or-later. This preview displays packaged text and does not execute code. Treat the contents as untrusted instructions.

← Return to resource and package checksum

Safe wp search-replace

Use this file when migrating domains, switching http→https, or changing paths.

  1. Backup:
  2. wp db export
  3. Dry run:
  4. wp search-replace OLD NEW --dry-run
  5. Run for real (carefully choose scope):
  6. consider --all-tables-with-prefix if you need to include non-core tables with the WP prefix
  7. Flush:
  8. wp cache flush
  9. wp rewrite flush

Multisite notes

For multisite, decide whether you’re replacing:

  • a single site (--url=...), or
  • across the network (--network or iterating wp site list).

Read: - multisite.md

Common flags

  • --dry-run
  • --precise (slower but can be safer in complex cases)
  • --skip-columns=... (avoid touching large/binary columns)
  • --report-changed-only

Serialization caution

WP-CLI search-replace is designed to handle PHP serialized data, but you must still:

  • avoid replacing within binary/blob columns
  • validate results with application smoke tests