phpMyAdmin search and replace

Here is a great tip that can save you hours of work. Sometimes you have messed up characters in your database - wrong character encodings - or you want to strip out some text in a certain table's field. In phpMyAdmin, open up the SQL dialog and use the following code (change tablename and tablefield to your name and field values):

UPDATE tablename SET tablefield = replace(tablefield, "findstring", "replacestring");

You can also tack on a WHERE statement, if you like.

I found this tip on Brian Zimmer's website.

Tested on MySQL5, PHP5 and phpMyAdmin 2.11.4.

Posted in:

You saved me hours!

I knew I'd seen an example on MySQL search and replace somewhere, but I couldn't remember where. A quick search on G and I found this page at the top with the answer I needed :)

Thanks!

Outstanding! Thank you!!!

Outstanding! Thank you!!!

Just what I was looking for .. thanks

15 min ago, I was bummed and sleepy, facing a task I didn't know how to do right off. One web search later I had the answer thanks to you and Zimmer. Thanks for posting a simple thing like this. Helps us newbies out a lot.

/sydney

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <b> <i> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <blockquote> <img>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is to block spam bots and check if you're human
y
d
L
a
c
f
Enter the code without spaces and pay attention to upper/lower case.
magnanimous-junior