共计 819 个字符,预计需要花费 3 分钟才能阅读完成。
我们经常会遇到网站更换域名遇到很头疼的事情,更换后大量的图片等网站资源会出现404错误。主要原因就是迁移网站、更换域名之后数据库中的网站资源域名还是原来的老域名。通过以下sql命令可以一键更换全站所有域名。

注意更改命令中的数据库前缀,如果还是不会或者其他问题请联系站长协助。
UPDATE wp_options SET option_value = REPLACE(option_value, 'https://old.yuucn.com', 'https://new.yuucn.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = REPLACE (post_content, 'https://old.yuucn.com', 'https://new.yuucn.com');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'https://old.yuucn.com','https://new.yuucn.com');
UPDATE wp_comments SET comment_content = REPLACE (comment_content, 'https://old.yuucn.com', 'https://new.yuucn.com');
UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, 'https://old.yuucn.com','https://new.yuucn.com');
UPDATE wp_posts SET guid = REPLACE (guid, 'https://old.yuucn.com', 'https://new.yuucn.com') WHERE post_type = 'attachment';

正文完
扫上方小程序码下载文中资源