A MySQL query to find & replace text in your database

Problem: Help! I need to replace some words with something else in my database.

Solution: Use the replace() function to do a search and replace query.

UPDATE table_name SET
table_field=REPLACE(table_field,"old_text","new_text");

Here’s an example:

UPDATE wp_posts SET
post_content=REPLACE(post_content,"localhost","www.cybervaldez.com");

Easy as pie!

120x20 thumb black A MySQL query to find & replace text in your database

Some links that you might find useful [External]:

Still can't see what you're looking for?



Leave a Reply

Anti-Spam Protection by WP-SpamFree