---
title: "How do I update all URL's inside a WordPress database using WP-CLI?"
url: "https://ploi.io/documentation/deployment/how-do-i-update-all-urls-inside-a-wordpress-database-using-wp-cli"
published: "2023-03-09"
last_updated: "2023-03-09"
---

# How do I update all URL's inside a WordPress database using WP-CLI?

Updating URLs in a WordPress database can be a daunting task, especially if you have a large number of posts, pages, and media files. However, with the help of the wp-cli command-line interface, this process can be simplified and made more efficient.

In Ploi, it's possible to easily 1-click install the WP-CLI from the panel, inside the Manage tab on server level:

[![](https://ploi.io/storage/DwUNZMle2KxOUTkXJGSD2yDFK0lxMl7E0roxtsMJ.png)CleanShot 2023-03-09 at 13.28.20.png 146.79 KB](https://ploi.io/storage/DwUNZMle2KxOUTkXJGSD2yDFK0lxMl7E0roxtsMJ.png) Here's a step-by-step guide on how to update all the URLs in your WordPress database using wp-cli:

1\. Backup your WordPress database, before making any changes to your WordPress database, it is essential to back it up. You can do this with Ploi if you have the correct subscription, or use a client like TablePlus or phpMyAdmin.

2\. Navigate to the root directory of your WordPress installation using the cd command. For example, if your WordPress site is located in the **/home/ploi/myblog.com/public** directory, you would type:

```
cd /home/ploi/myblog.com/public
```

3\. Open the wp-cli interface, simply type **wp** followed by the command you want to run. For example, to see a list of available commands, you would type:

```
wp help
```

4\. Update the URLs in your WordPress database, you'll need to run two wp-cli commands. The first command updates the site URL:

```
wp search-replace 'https://myblog.com' 'https://mysuperblog.com' --skip-columns=guid
```

In this command, replace **https://myblog.com** with your site's old URL and **https://mysuperblog.com** with your site's new URL. The **--skip-columns=guid** argument tells wp-cli to skip updating the GUID column, which contains the permanent link to each post or page.

The second command updates the home URL:

```
wp option update home 'https://mysuperblog.com'
wp option update siteurl 'https://mysuperblog.com'
```

This command updates the home URL stored in the options table of your WordPress database.

5\. Once the commands have finished running, verify that the URLs have been updated by visiting your WordPress site and checking that all links and images are working correctly.

That's it! By following these steps, you can update all the URLs in your WordPress database quickly and easily using wp-cli. Remember to always back up your database before making any changes.