WordPress 批量更换旧网站或内容 Mysql 语句

技术期刊1个月前发布 voidke
0 0

在WordPress程序的使用中,我们经常会遇到新旧域名替换等操作。通常,我们会操作Mysql数据库,以便更快、更完整地进行全面替换。

在Mysql管理界面执行以下sql语句:

注:以下代码中的 000000 代表新网站, 111111 所有代表旧网站的网站都需要改成自己的网站。建议在操作前备份数据库,防止手残。

例如,您想使用新域名 https://voidke.com 替换旧域名 https://www.voidke.com。

update wp_posts set `post_content`=replace(`post_content`,“111111111”;
update wp_posts set `post_excerpt`=replace(`post_excerpt`,\'000000\',\'111111\');
update wp_posts set `guid`=replace(`guid`,“111111111”;
update wp_commentmeta set `meta_value`=replace(`meta_value`,\'000000\',\'111111\');
update wp_comments set `comment_author_url`=replace(`comment_author_url`,\'000000\',\'111111\');
update wp_comments set `comment_content`=replace(`comment_content`,\'000000\',\'111111\');
update wp_postmeta set `meta_value`=replace(`meta_value`,“111111111”;
update wp_usermeta set `meta_value`=replace(`meta_value`,“111111111”;
update wp_users set `user_url`=replace(`user_url`,“111111111”;

PS:该方法没有操作替换 wp_options 表中的数据不建议一次性操作,因为表中有一些非常规字符串的数据类型。当然,如果您想尝试头部铁,您也可以执行以下sql语句。此操作有风险,一些主题或插件的配置可能无效。

update wp_options set `option_value`=replace(`option_value`,“111111111”;
© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...