[Beginner’s Guide] How to Change WordPress Image URLs to HTTPS without Plugin

Migrating your WordPress website from HTTP to HTTPS? You have to change the image urls and internal links to https in the old pages to avoid mixed content warnings.

This can be done easily via WordPress plugins or adding a few lines in functions.php. For good and all, you can also run a few commands to your MySQL database. And here’s the step by step guide.

If you have phpmyadmin installed and enabled in your server, just connect to phpMyAdmin, navigate to the correct database, activate SQL pop-up window, and finally type and run the SQL queries.

1. First connect to your remote server. Then run command to make a backup of your MySQL database:

mysqldump -u USERNAME_HERE -p DATABASE_NAME > mydatabase.sql

NOTE: you have to replace USERNAME_HERE and DATABASE_NAME in the command.

Forgot your database name, username, or password? Navigate to your wordpress site root directory (usually /var/www or /usr/share/nginx), and run command to check out the wp-config.php

cat wp-config.php |more

2. After backup your database, login to MySQL server via command:

mysql -u root -p

Forgot the root password? You can also login with the user set in wp-config.php:

mysql -u USERNAME_HERE -p

3. After login to MySQL server, you can run command to list database:

show databases;

And select your wordpress database (check it out in wp-config.php) via command:

use DATABASE_NAME;

4. Finally run a few commands to switch to HTTPS urls. Replace fostips.com in command with your sitename.

  • Update image urls, internal links to https:
    UPDATE wp_posts SET post_content = replace(post_content, 'http://fostips.com', 'https://fostips.com');
  • Update pinged links to https:
    UPDATE wp_posts SET pinged = replace(pinged, 'http://fostips.com', 'https://fostips.com');
  • Update comment author url with http version of your site url:
    UPDATE wp_comments SET comment_author_url = replace(comment_author_url, 'http://fostips', 'https://fostips.com');
  • Update comment content contains http version of your site url:
    UPDATE wp_comments SET comment_content = replace(comment_content, 'http://fostips.com', 'https://fostips.com');

Finally run exit; to log out Mysql server. And in WordPress General Settings do update your site url to https.

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.