Change WordPress Domain Name

If you ever decided to change your WordPress site’s domain, firing up following MySQL queries can reduce internal redirections.


  1. is old-domain
  2. is new-domain


UPDATE `wp_options` SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE `wp_posts` SET post_content = replace(post_content,'','');
UPDATE `wp_postmeta` SET meta_value = replace(meta_value,'','');
UPDATE `wp_comments` SET comment_author_url = replace(comment_author_url,'','');
UPDATE `wp_comments` SET comment_content = replace(comment_content,'','');
UPDATE `wp_commentmeta` SET meta_value = replace(meta_value,'','');

Above will take care of, options table, posts & comments. If you have any other database table/column which need change you can run queries like below any number of times:

UPDATE `TABLE_NAME` SET meta_value = replace(COLUMN_NAME,'','');


  1. Jeff Shaikh Avatar

    Nice outline of what needs to be changed. I guess you would have to do this if you had no choice, but I prefer to use wp-cli search-replace…. A lot less typing and it’s done with one command. There is even a –dry-run option.

Book a strategy call
with our experts

No obligation. Limited slots.

Contact Form Business Enquiry

"*" indicates required fields

Please attach any RFP, project specification, or document that you would like to share.
Drop files here or
Max. file size: 5 GB.
    This field is for validation purposes and should be left unchanged.