How to find and replace text string in all MySQL tables

The following tutorial is helpful if you have a MySQL database and need to find and replace all occurrences of a string, for example, replacing “” with “”. This is useful if you are moving or cloning your website to another domain, especially if you are using software such as WordPress.

First, go to your old domain name and export the ENTIRE database, including enabling the option to “drop tables” if they’re already present. If you’re using PHPMyAdmin, you’ll want to select the option as highlighted below. To see these options, choose the Export Method: Custom – display all possible options.

how to find and replace text string in all mysql tables

Once you’ve obtained your .sql file, open it up in a text editor like Notepad, and do a find-and-replace of the string that you’re looking for.

After which, the next step is to import the .sql file back into your MySQL database. The “drop tables” command will remove all the existing tables, and then import your data. You now have a database with all the occurrences of your text string properly replaced.

Leave a Reply

Your email address will not be published. Required fields are marked *