php開発日記

PHP開発で日々発生した対応などの備忘録

wordpress ドメインが変更された場合 DBへの対処

wordpressはDB内にドメイン名を保持しているので

ドメインが変わった場合は以下のように変更する。

 


(確認) select * from wp_options where option_value like '%(移行前ドメイン)%'
(更新) UPDATE wp_options SET option_value=REPLACE(option_value,"(移行前ドメイン)","(移行後ドメイン)");

(確認) select * from wp_posts where post_content like '%(移行前ドメイン)%'
(更新) UPDATE wp_posts SET post_content=REPLACE(post_content,"(移行前ドメイン)","(移行後ドメイン)");

(確認) select * from wp_posts where guid like '%(移行前ドメイン)%'
(更新) UPDATE wp_posts SET guid=REPLACE(guid,"(移行前ドメイン)","(移行後ドメイン)");

(確認) select * from wp_postmeta where meta_value like '%(移行前ドメイン)%'
(更新) UPDATE wp_postmeta SET meta_value=REPLACE(meta_value,"(移行前ドメイン)","(移行後ドメイン)");


※ 移行前ドメインは http://またはhttps://から記述