Find and replace in MySQL

Searching and replacing a word or text in a MySQL table is easy. If you want to replace the word wang with wand in the text

A magic wang… this was what Harry had been really looking forward to.

use the command

update table set field = replace(field, 'wang', 'wand') where instr(field, 'wang') > 0;

where field needs to be the name of the database field that you want to search. Wang will be changed to wand then while the rest of the content will remain the same.

Find and replace in MySQL
Share this