a function we use a lot is to quickly find and replace all references to a piece of text, word, whatever .. in a database table or the database as a whole.
Common usages are:
- Find and replace a word across all WordPress posts
- Find and replace an HTMl Tag that appears in a line of code in a database
- Find and replace part of a URL or image reference in a database
- Find and replace an incorrect spelling in a database table or piece of content
As a baseline, the command is easy:
1 UPDATE `your_table_name` SET `your_field_name` = replace(your_field_name, 'text you want to find', 'text you want to replace')
That’s it. It is that simple. Of course, you will want to backup your database before doing this like a good little developer, but we assume you already knew that. You can execute this command from command line within your MySQL account, or you can do this in a web-based tool such as PHPMyAdmin.