How to find and replace text string in all MySQL tables

/, Tutorials & Tips/How to find and replace text string in all MySQL tables

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 “www.YourOldDomain.com” with “www.YourNewDomain.com”. 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.

Similar Posts:

By |2015-05-16T15:30:33+00:00May 16th, 2015|Programming & Code, Tutorials & Tips|0 Comments

About the Author:

Alvin Poh lives in Singapore, and is interested in marketing, techy stuff, and likes to just figure out how the two can work with each other. He can also be found on Google+.

Leave A Comment


*