If you’re okay with executing a few MySQL queries, you can quickly find and replace any URL in your WordPress MySQL database. In this tutorial, you’ll learn how to use phpmyadmin to replace HTTP with HTTPS.
Find HTTP Occurrences
The first thing to do is find all occurences of URLs that start with HTTP in your WordPress database. To do this, sign in to phpmyadmin and click on your database on the left side.
In the Search tab, enter your HTTP domain name surrounded by the wildcard character %.
It’s also good to search for the non-www version of your website too.
You’ll see a table of matching row similar to this.
Our goal is to eliminate any matches from the search results. To do this, we will execute an SQL query to replace HTTP with HTTPS for each table.
Replace HTTP with HTTPS in phpmyadmin
Now that we know how many URLs start with HTTP, we can begin to replace them with HTTPS.
First click on Browse for one of the matching tables in the search results from above and find the column or columns that contain HTTP URLs.
Next in the Query tab (it’s a good idea to open another window), copy the following SQL query and replace t with the name of the table and col with the name of the column containing HTTP URLs. Also replace example.com with your domain name.
UPDATE t SET col = REPLACE(col, 'http:', 'https:') WHERE col LIKE '%http://example.com%';
For example, in the search results above, if I found URLs that start with HTTP in guid column of the the wp_posts table, my MySQL query would look like this.
UPDATE wp_posts SET guid = REPLACE(guid, 'http:', 'https:') WHERE guid LIKE '%http://tonyteaches.tech%';
You can first Simulate query to see how many rows will be replaced and finally hit Go to execute the query.
Repeat this process for each table that has occurrences of HTTP URLs. You re-run the search query to keep track of your progress along the way.
Here is a video that will walk you through the process.
If you have any questions, please let me know in the comments section below.