Last active
May 6, 2020 17:29
-
-
Save Phlow/e8f7b3835652af289a31 to your computer and use it in GitHub Desktop.
MySQL Queries When Moving WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
There's a better tool https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ | |
MySQL Queries When Moving WordPress | |
To use this snippet, you have to: | |
1. Change the table prefix according your installation. In the example it's: wp_ | |
2. Change http://old-domain.com to your old domain. | |
3. Change http://new-domain.com to your new domain. | |
Please have a close look if you used the domain with or without WWW. | |
Generator › http://adambalee.com/tools/moving-wordpress-sql-generator.php | |
Or use a plugin › https://wordpress.org/plugins/duplicator/ | |
*/ | |
UPDATE wp_options SET option_value = replace(option_value, 'http://old-domain.com', 'http://new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = replace(guid, 'http://old-domain.com', 'http://new-domain.com'); | |
UPDATE wp_posts SET post_content = replace(post_content, 'http://old-domain.com', 'http://new-domain.com'); | |
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://old-domain.com','http://new-domain.com'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget about
UPDATE wp_postmeta SET meta_value .....
😉