~$perlat kociaj
// free-tools

WP Search & Replace

Generate SQL queries for search and replace operations in MySQL databases. Common for WordPress migrations when changing domains or URLs.

SQL Query
UPDATE `wp_options` SET `option_value` = REPLACE(`option_value`, 'http://old-domain.com', 'https://new-domain.com') WHERE `option_value` LIKE '%http://old-domain.com%';

UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`, 'http://old-domain.com', 'https://new-domain.com') WHERE `post_content` LIKE '%http://old-domain.com%';

UPDATE `wp_posts` SET `guid` = REPLACE(`guid`, 'http://old-domain.com', 'https://new-domain.com') WHERE `guid` LIKE '%http://old-domain.com%';

UPDATE `wp_postmeta` SET `meta_value` = REPLACE(`meta_value`, 'http://old-domain.com', 'https://new-domain.com') WHERE `meta_value` LIKE '%http://old-domain.com%';

UPDATE `wp_usermeta` SET `meta_value` = REPLACE(`meta_value`, 'http://old-domain.com', 'https://new-domain.com') WHERE `meta_value` LIKE '%http://old-domain.com%';

UPDATE `wp_comments` SET `comment_content` = REPLACE(`comment_content`, 'http://old-domain.com', 'https://new-domain.com') WHERE `comment_content` LIKE '%http://old-domain.com%';

UPDATE `wp_comments` SET `comment_author_url` = REPLACE(`comment_author_url`, 'http://old-domain.com', 'https://new-domain.com') WHERE `comment_author_url` LIKE '%http://old-domain.com%';
WP CLI (recommended)
wp search-replace 'http://old-domain.com' 'https://new-domain.com' --all-tables --dry-run
# Remove --dry-run when ready to execute

Related Tools