使用MySQL查询在整个表格中查找和替换文本

问题描述:

通常,我使用手动查找来使用phpmyadmin替换MySQL数据库中的文本.我现在已经厌倦了,如何在phpmyadmin的整个表中运行查询来查找文本并将其替换为新文本?

Usually I use manual find to replace text in a MySQL database using phpmyadmin. I'm tired of it now, how can I run a query to find and replace a text with new text in the entire table in phpmyadmin?

示例:找到关键字domain.com,替换为www.domain.com.

Example: find keyword domain.com, replace with www.domain.com.

用于single table更新

 UPDATE `table_name`
 SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

来自multiple tables-

如果要从所有表中进行编辑,最好的方法是先将dump然后再find/replace并上传回去.

If you want to edit from all tables, best way is to take the dump and then find/replace and upload it back.