Updating the URL of a WordPress website with SQL commands

Use the following commands to change the URL of a WordPress website directly inside the mysql database:

UPDATE wp_options SET option_value = replace(option_value, 'http://oldaddress.com', 'http://newaddress.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://oldaddress.com','http://newaddress.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://oldaddress.com', 'http://newaddress.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://oldaddress.com','http://newaddress.com');Code language: JavaScript (javascript)