Update a MySQL table from the command line (find and replace)

I thought this might be helpful to some of you out there, as I routinely have to do this myself. Need to update a table, or a lot of rows of data in MySQL? Here is a handy Find and Replace SQL script to run at the command line.

mysql> update TABLENAME set FIELDNAME  = replace(FIELDNAME, 'X','Y');

In the above example, X is the existing text and Y is the new text you want to replace with. Have fun!

Leave a Comment