Replace text on all tables of MySQL Database

2019-08-29 04:54发布

问题:

For a single table, following SQL query works fine to replace text:

UPDATE `TABLE_NAME` SET `COLUMN_NAME` = replace(COLUMN_NAME, 'Old_Text', 'New_Text')

I want to replace the keyword 'August' from the whole database to 'September'. Is there anything except manual find/replace on the dump for replacing the text from whole database? The dump would be of no help as database size is very huge.

回答1:

If you are using Linux/Unix and are sure you don't have any fields/tables namned August, you could use sed to replace every text August with September:

sed -i 's/August/September/g' mydumpfile.sql