Home Articles Platform info WordPress Update URLs in database

Update URLs in database

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.

ssh [email protected]

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.

Example

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 help you?