Thursday, February 10, 2022
The Great Tit
Updated: 10. 2. 2022, Added: 10. 2. 2022

Update WordPress database URL after manual migration

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/

Did I help you? Fuel our WordPress journey
Beep this article to your friends!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram