人生若只如初见 - 数据库 2026-04-12T09:07:00+08:00 Typecho https://blog.ilingku.com/feed/atom/tag/%E6%95%B0%E6%8D%AE%E5%BA%93/ <![CDATA[MySQL批量替换指定字符串]]> https://blog.ilingku.com/archives/23/ 2026-04-12T09:07:00+08:00 2026-04-12T09:07:00+08:00 kevin 直接用 MySQL语句就可以执行:

UPDATE `表名` SET `字段名` = REPLACE(字段名, '原始字符串', '替换成其他字符串')

多个词语批量替换语句:

UPDATE 表名 SET 字段名 = REPLACE(REPLACE(字段名, '被替换1', '替换成1'), '被替换2', '替换成2');

比如我要替换的我旧域名:

UPDATE `wp_posts` SET `post_content` = replace(`post_content`, 'https://old.com/', 'https://new.com/') 
]]>