WP-CLI & wp search-replace

Sometimes you need to update a URL in your database, like when you move your site to a new domain. A very easy method of doing so is to use the command-line tool WP-CLI.

WP-CLI comes preinstalled on all bolt, the only thing you need to do is connecting with SSH. You can find an article on that here if you don't know how to:

ssh user@server

When you're connected with SSH, navigate to your webroot/public/ directory. Here you will find your WordPress installation.

With the command wp search-replace you 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.

Did this answer your question?