MySql Find Replace String Function

I was looking to be able to find and replace references to a clients IP that were hard coded into product pages and such. Just a quick reference for myself and others whom may want to find and replace something from within a their database.

In order to use the following code I had to search for tables that contained what I wanted to replace. Then I could click on the table and find the specific row within the table that had the IP I wanted to replace. Type in the Table Name, then Row Name as well as what you are looking to find and replace with accordingly based on the following short code. The bolded items below have to be updated to match what you are trying to accomplish. Replace [] brackets text with appropriate info.

update [table_name] set [field_name] = replace([field_name],’[string_to_find]‘,’[string_to_replace]‘);

You may be able to find another database string function but I found this one safe and easy to use. It also allowed me to backup individual tables in case anything happened.

Speak Your Mind