Search and Replace MySQL using PHPMyAdmin



Search and Replace MySQL using PHPMyAdmin

This is a life-saver: an easy way to search any table inside your database and replace one string of text with another. It works like a charm. But be careful, search first to see the results of your query before you commit the changes, and always backup prior to any database work.

Here is how you test the waters safely:

SELECT * FROM `wp_posts` WHERE `post_content` LIKE '%oops%'

Translation:

SELECT * FROM `table_name` WHERE `field_name` LIKE '%unwanted_text%'

And here is how you do some damage:

UPDATE `wp_posts` SET `post_content` = replace(post_content, 'oops', 'much better')

And translated:

UPDATE `table_name` SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

Related posts:

  1. Search and Replace a Custom Field in WordPress using PHPMyAdmin
  2. How to Bulk Import into a MySQL Database
  3. How to Add Uploaded Media to WP-DownloadManager
  4. Delete Comment Spam using a Cron Job
  5. Replace Text on Click Using JavaScript

Comments

2 Responses to “Search and Replace MySQL using PHPMyAdmin”

  1. Gosip Artis Terbaru on December 5th, 2008 6:21 pm

    great, this is what i’m looking for. thanks for sharing

  2. [n3rve] on July 11th, 2009 6:10 am

    Thanks for sharing, exactly what I needed :D