Aleš Sýkora / February 10, 2022 / 0 comments

Update WordPress database URL after manual migration

Post summary: Run this SQL commands in database and do not forget to change the database prefix to your one. Do this on your own risk. You can also try to run this without / at the end of URL’s. After you successfully run this SQL commands, go to wp-config.php file and change this lines to mach…

Run this SQL commands in database and do not forget to change the database prefix to your one. Do this on your own risk.

UPDATE db_prefix_options SET option_value = replace(option_value, 'https://old.url/', 'https://new.url/') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE db_prefix_posts SET guid = replace(guid, 'https://old.url/','https://new.url/');

UPDATE db_prefix_posts SET post_content = replace(post_content, 'https://old.url/', 'https://new.url/');

UPDATE db_prefix_postmeta SET meta_value = replace(meta_value,'https://old.url/','https://new.url/');

UPDATE db_prefix_usermeta SET meta_value = replace(meta_value, 'https://old.url/','https://new.url/');

UPDATE db_prefix_links SET link_url = replace(link_url, 'https://old.url/','https://new.url/');

UPDATE db_prefix_comments SET comment_content = replace(comment_content , 'https://old.url/','https://new.url/');

You can also try to run this without / at the end of URL’s. After you successfully run this SQL commands, go to wp-config.php file and change this lines to mach your new database credentials:

define('DB_NAME', 'databasename');

/** MySQL database username */
define('DB_USER', 'username');

/** MySQL database password */
define('DB_PASSWORD', 'password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

And do not forget to change the salt keys in wp-config too. Get new ones here: https://api.wordpress.org/secret-key/1.1/salt/

Fuel my passion for writing with a beer🍺

Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻

0 comments

Share Your Thoughts