Pure SQL Approach to Globally Search and Replace Strings in MySQL Database

Say, in MySQL, if you would like to find the string 'http://www.guiguan.net' in a database and replace all of its occurrences (from all columns/fields of all tables in the database) with another string 'https://www.guiguan.net', because that you just moved to a more secure world, then you can achieve this purely using native SQL statements in MySQL.

First, launch your favourite MySQL client, such as PHPMyAdmin, Adminer or just CLI, select your target database and execute the following SQL statements to define your  global_replace procedure:

Then, you just call the stored procedure:

to replace all occurrences of 'http://www.guiguan.net' across your database with the string 'https://www.guiguan.net'. Done.

In the future, you can just call global_replace again to replace more strings. If you would like to remove the stored procedure, then just:

If you wish, you can put all the statements together in a single execution.