brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp search-replace --dry-run shows what would change before it touches your database

Database
~/tips/tip-wp-search-replace-dry-run

wp search-replace 'http://old.example' 'https://new.example' --dry-run

Counts the replacements WP-CLI would make in your WordPress database without changing anything.

Moving a WordPress site to a new domain means replacing the old address in the database. That is the kind of command I want to see the result of before it runs for real.

With WP-CLI, add --dry-run:

wp search-replace 'http://old.example' 'https://new.example' --dry-run

It prints a table with how many replacements it would make per table and column, and writes nothing. When the numbers look sane, run the same command without the flag. WP-CLI handles serialized data properly, which a plain SQL replace does not, and that is why I would use it for this.

Caveat: a dry run is not a backup. Export the database first (wp db export) before you do the real run.

Further reading: wp search-replace (WP-CLI handbook), On this site: wp option list –autoload=on –format=total_bytes shows what every page load drags along, On this site: wp search-replace –dry-run shows what a WordPress domain change would touch

More Database tips mariadb -e 'CREATE DATABASE IF NOT EXISTS blog' mariadb-dump --no-create-info --insert-ignore shop orders > orders-rows.sql SELECT table_schema, table_name, CHECKSUM TABLE shop.orders; services: All Database tips (53) All topics

Link