Here are the required MySQL queries to change WordPress HTTP to HTTPS – including post images and all other contents. This is the right fix. The reader should read our previous guides – Changing Old WordPress to HTTPS From HTTP, Needed Plugins and Snippets for WordPress HTTPS Setup, Solution for WordPress HTTPS and Feedburner 404, XCache and W3 Total Cache WordPress on High End Setup and How to Export WordPress MySQL Database on Rackspace Deployment.
MySQL Queries to Change WordPress HTTP to HTTPS : Why Hardcoding?
If you do not change the old posts’ URLs from relative path using some plugin to genuine HTTPS, W3TC Plugin’s Page Enhanced Disk Cache will not work – it will pull the HTTP image URLs from Post content and your SSL / HTTPS will break. For the sake of SEO, it is better to use Post Images from own URL instead of CDN. Even if you use CDN for Post Images, this the right fix. The reason W3TC Plugin fails because it pulls the Post data from Database, it ignores any Plugin’s filter function. So, with SSL, these commands are mandatory to know, plus; using this commands, you can actually change the URLs of any non-SSL content – like a signature at the end of the post which is not inserted by any Plugin.Advertisement
MySQL Queries to Change WordPress HTTP to HTTPS
So, we will be using WordPress MySQL database from Command Line, like the guide How to Export WordPress MySQL Database on Rackspace Deployment. SSH to your Database server as root and login to MySQL as Root :
# change the IP
mysql -u root -p
# provide mysql root admin's password
# mysql interactive mode
# mysql >
# if you commit error, it will become
# mysql >
# this is asking values due to your error
# type \c and hit enter to get back to
# mysql >
First take a backup. This is important. Then,
| Database |
| information_schema |
| mysql |
| your-wordpress |
Select your database :
# database changed will be the output
Optionally, see the tables :
This command changes all http to https in
UPDATE wp_options SET option_value = replace(option_value, 'http://thecustomizewindows.com', 'https://thecustomizewindows.com') WHERE option_name = 'home' OR option_name = 'site url';
https://thecustomizewindows.com. You only need to see for Errors in output. Other two parameters are not needed to observe.
We are changing the POST GUID :
UPDATE wp_posts SET guid = replace(guid, 'http://thecustomizewindows.com','https://thecustomizewindows.com');
Now, this is for Post Content (including images)
UPDATE wp_posts SET post_content = replace(post_content, 'http://thecustomizewindows.com', 'https://thecustomizewindows.com');
You should change the Post Meta Too :
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://thecustomizewindows.com','https://thecustomizewindows.com');
Clear Page Cache, Deactivate Page Cache; deactivate any WordPress Plugin which changes URLs to HTTPS or makes relative. On Crome Browser’s developer tool’s console, you will see the Post Images are HTTPS now. This method is better than Search and Replace Plugin. PHPMyAdmin is usually not used in high end setup for better security. Why you will need PHPMyAdmin, you can see things from Command Line.