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’ve launched Accelerated Domains!
Accelerated Domains is a service that greatly improves and optimizes your site on these four areas: Performance Scalability, Security, Carbon footprint.