Search and replace
WordPress stores full addresses, such as https://old.example.com/wp-content/uploads/…, all through its database. When an address changes, those need replacing everywhere, including inside serialized plugin settings, which a plain SQL replace would break. WP-CLI’s search-replace handles this correctly.
When Netkeel does it for you
Section titled “When Netkeel does it for you”You don’t need to run a search and replace yourself when you:
- take a website live from its preview address, or connect your domain to it;
- create a staging copy, refresh staging or push staging live with the database;
- clone a website to a new domain.
In each case Netkeel replaces the old address with the new one in the copied database.
Run it yourself
Section titled “Run it yourself”Use the WP-CLI terminal for anything else, such as moving from http:// to https:// or replacing an old domain left behind by a migration.
-
Take a backup. Click Create backup on the website’s overview, and wait for it to finish. A search and replace can’t be undone otherwise.
-
Do a dry run. Open WordPress › WP-CLI terminal and run:
search-replace 'https://old.example.com' 'https://example.com' --dry-runNothing changes. WP-CLI lists each table and how many replacements it would make.
-
Check the numbers. If they look wrong, adjust the search text and run the dry run again.
-
Run it for real. Run the same command without
--dry-run. -
Clear the cache. Click Purge cache so visitors get the updated pages.
Useful options
Section titled “Useful options”--dry-run: show what would change, without changing anything.--skip-columns=guid: leave post GUIDs alone. WordPress uses them as permanent IDs for feeds.--precise: slower, but catches values the fast mode might miss.--report-changed-only: list only the tables where something changed.
Good to know
Section titled “Good to know”- Team members who have access to only some websites can run
search-replaceonly with--dry-run. Ask the workspace owner to run the real one. - On a very large database, run it during a quiet time, or run it over SSH (see Hosting › SSH / SFTP) where you can watch it work.
- Try it on a staging copy first if the change is big or you aren’t sure of the result.