Cara Mengubah Domain pada WordPress Self Hosted

set @old = ‘domainlama.com’;
set @new = ‘domainbaru.com’;
set @pref = ‘wp’;

set @s1 = CONCAT(‘UPDATE ‘,@pref,’_options SET option_value = replace(option_value, “‘,@old,'”, “‘,@new,'”) WHERE option_name = “home” OR option_name = “siteurl”;’);
set @s2 = CONCAT(‘UPDATE ‘,@pref,’_posts SET guid = replace(guid, “‘,@old,'”, “‘,@new,'”);’);
set @s3 = CONCAT(‘UPDATE ‘,@pref,’_posts SET post_content = replace(post_content , “‘,@old,'”, “‘,@new,'”);’);
set @s4 = CONCAT(‘UPDATE ‘,@pref,’_postmeta SET meta_value = replace(meta_value, “‘,@old,'”, “‘,@new,'”);’);

PREPARE stmt1 FROM @s1;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;

PREPARE stmt2 FROM @s2;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;

PREPARE stmt3 FROM @s3;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;

PREPARE stmt4 FROM @s4;
EXECUTE stmt4;
DEALLOCATE PREPARE stmt4;