mySQL query to update all HTTP to HTTPs

Posted by: Alex on September 4, 2014

Ever needed to update all links from HTTP to HTTPS in your database?

This query allows just that, simply change table_name_here, the 2x column_name_here occurrences and the yourdomain to your relevant info, and run! It will search that whole column (column_name_here) for http://yourdomain and replace it with your new https://yourdomain.

UPDATE table_name_here SET column_name_here = REPLACE(column_name_here, 'http://yourdomain', 'https://yourdomain')

It’s to be noted that this query is completely reusable for pretty much any situation where you need to replace all occurrences of a string with another string. So give it a try the next time you need to update and replace a MySQL database string with another string.