MySQL Find & Replace

As an artefact to upgrading my database from mySQL 4.0 to mySQL 5.0 (so I could apply the latest WordPress update), I noticed a whole heap of  ‘Â’ symbols had appeared in my previous posts.

I started to edit them out, then realised there must be a better way. Thanks to Brad J Frey’s blog, I fixed it in about 15 seconds.

All you have to do is log into your PHPMyAdmin control panel for the database you want to change, then choose the SQL button, as shown here:

PHPMyAdmin For Database

PHPMyAdmin For Database

This opens up a window – make sure you select the SQL tab:

MySQL Query Window

MySQL Query Window

This is the query I used to get rid of the  symbols:

UPDATE `wp_posts` SET post_content = replace(post_content,””,””);

The general format is:

UPDATE `tablename` SET fieldname = replace(fieldname,”what-to-replace”,”what-to-replace-with”);

Just hit GO and the replace operation is done very quickly.

EDIT 22/12/2009: But even better than this, I found a plugin for WordPress which does the search and replace for you. Thanks to thedeadone.net for that. It’s much better.

(Visited 14 times, 1 visits today)