Sometimes it happens that we need to change maxively in the mysql database, a specific text. Not only change a text, a word, a number, that can be done manually. But when we must change that text in more than one table, sometimes, even change several texts in the same table and in different fields.
How we do to replace that text in different tables or fields, without having to waste a lot of time. Here are the steps:
1. Log in to your hosting Control Panel (cPanel, Plesk, etc). In the Databases section, choose your database and click in phpMyAdmin.
2. Now you are in the phpMyAdmin control panel.
3. The easiest way to find that text you need to replace is to do a search in the mysql database. As simple as going to SEARCH, choose the parameters you need and click GO. It will show you the result of your search.
4. Choose one of the tables where you want to change the text, click on it and it will open all the results found in that same table, but it will also show you the exact field where the result of your search is. Write down the name of the table and the name of the field.
5. Go back to the main page of the database and click on the SQL button. You will see a text box where you can insert a query, using the REPLACE command, as follows:
UPDATE table_name SET field_name = REPLACE(field_name,'text to search','new text');
6. Next you will click the GO button and it will show you the final result, showing the amount of tables that have been modified. You will do the same with the rest of the fields, if necessary.
Important: Make a backup of the database, before making any query. In the case of making an error, the tables are deleted, the database is uploaded again and the problem solved. You can also make a backup of only the table you want to modify, much better if you have a very large database.
The servers with the phpMyAdmin in the latest versions (depending on your hosting), have a SIMULAR QUERY option that can help you to show the result before giving the final OK to the query, so that you save some headaches.