Sometimes you need to update a URL in your database, like when you move your site to a new domain or when you’ve moved a site to and from a temporary staging URL. A very easy method of doing so is to use the command-line tool WP-CLI and its
wp search-replace command.
WP-CLI comes preinstalled on all Bolts, the only thing you need to do is connecting with SSH.
When you’re connected with SSH, navigate to your
webroot/public/ directory. Here you will find your WordPress installation.
With the command
wp search-replaceyou can easily change your URLs.
wp search-replace [OLD URL] [NEW URL] --all-tables
This command will replace the [OLD URL] with the [NEW URL] in all tables, in the database.
When you run this command you should see all the tables in your database and in which tables the replacement happened
WP-CLI man pages
Too look at what else WP-CLI can do for you WordPress site is by typing the command
wp, and the man pages should pop up.
Give us your feedback on this article
Did this help you?
We have launched in the UK! 🇬🇧
Servebolt Cloud UK is now available to all clients. Our London data center will ensure that all clients with their majority of visitors in the UK experience extremely fast websites!