How to find & replace text in a MySQL Database

a function we use a lot is to quickly find and replace all references to a piece of text, word, whatever .. in  a database table or the database as a whole.

Common usages are:

  • Find and replace a word across all WordPress posts
  • Find and replace an HTML Tag that appears in a line of code in a database
  • Find and replace part of a URL or image reference in a database
  • Find and replace an incorrect spelling in a database table or piece of content

As a baseline, the command is easy:

That’s it. It is that simple. Of course, you will want to backup your database before doing this like a good little developer, but we assume you already knew that. You can execute this command from command line within your MySQL account, or you can do this in a web-based tool such as PHPMyAdmin.


Contact us today!

  • This field is for validation purposes and should be left unchanged.