场景模拟:
WordPress站点附件地址变更,于是按照网上教程执行以下SQL语句:
update wp_posts SET post_content = replace(post_content,'http://bk.phpwc.com/wp-content/uploads/','https://yz-xuwpfj.phpwc.net/wp-content/uploads/');
结果:附件URL已被更改,但再次编辑文章时发现URL地址又变成之前的bk.phpwc.com了:
经全库查询发现,附件URL地址替换涉及三个表wp_options、wp_postmeta、wp_posts,并非只有wp_posts,故需要执行三条语句,如下
UPDATE `wp_posts` SET `post_content` = replace( `post_content` , 'https://yz-xuwpfj.phpwc.net/wp-content/uploads/', 'https://yz-xuwpfj.phpwc.net/wp-content/uploads/'); UPDATE `wp_postmeta` SET `meta_value` = replace( `meta_value` , 'https://yz-xuwpfj.phpwc.net/wp-content/uploads/', 'https://yz-xuwpfj.phpwc.net/wp-content/uploads/'); UPDATE `wp_options` SET `option_value` = replace( `option_value` , 'https://yz-xuwpfj.phpwc.net/wp-content/uploads/', 'https://yz-xuwpfj.phpwc.net/wp-content/uploads/');