Replacing information inside a MySQL database

To do a search and replace in any MySQL database in phpMyAdmin. You do not need to download the database export at all, just run this simple command.

To search and replace a text string, start up phpMyAdmin, and click on your database name that you want to run the search and replace through. At the top of the window, click on the "SQL" tab.

To change many parts of a MySQL database use this simple string replace:

UPDATE `tablename` SET field = replace(field,"stringtofind","stringtoreplace")

You can add a WHERE clause onto this as well.

UPDATE `tablename` SET field = replace(field,"<p>","") WHERE `this` REGEXP '-0';

About Keiron

Web Developer based in the UK. Click here if you want to work with me