Wordpress change url (mysql query)

Thursday 28th, Jun, 2018 | #Wordpress


I asked myself many times: Can you change your WordPress domain later? How do you change your website URL?. If you need change url site from you worpress site, and you have mysql cpanel access, the best way is run this SQL script. CAUTION: first check the correct prefix name of you wp tables. (wp_).

Mysql query script to move wordpress site to new domain or url address



UPDATE wp_options SET option_value = REPLACE ( option_value, 'https://olddomian.com', 'https://newdomain.com' );

UPDATE wp_posts SET guid = REPLACE ( guid, 'hhttps://olddomian.com', 'https://newdomain.com' );

UPDATE wp_posts SET post_content = REPLACE ( post_content, 'https://olddomian.com', 'https://newdomain.com' );

UPDATE wp_postmeta SET meta_value = REPLACE ( meta_value, 'https://olddomian.com', 'https://newdomain.com' );

Other way is Change you wp-config.php file

define('WP_HOME','http://youraddress.com);
define('WP_SITEURL','http://youraddress.com');