Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Ugarz
Last active June 14, 2018 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ugarz/36d127607a553d61fd14d65936a25672 to your computer and use it in GitHub Desktop.
Save Ugarz/36d127607a553d61fd14d65936a25672 to your computer and use it in GitHub Desktop.
WP tricks database migration

Move your wordpress to localhost

Move your website parameters to new url

UPDATE wp_options
SET option_value = replace(option_value, 'http://mywebsite.fr', 'http://localhost/mywebsite')
WHERE option_name = 'home'
OR option_name = 'siteurl';

Replace urls for posts

UPDATE wp_posts
SET guid = replace(guid, 'http://mywebsite.fr', 'http://localhost/mywebsite');

Replace urls in posts content

UPDATE wp_posts
SET post_content = replace(post_content, 'http://mywebsite.fr', 'http://localhost/mywebsite');

Change url of your website

UPDATE wp_options
SET option_value = replace(option_value, 'http://mywebsite.fr', 'http://localhost/mywebsite')
WHERE option_name = 'home'
OR option_name = 'siteurl';

Change GUID's url

UPDATE wp_posts
SET guid = REPLACE (guid, 'http://mywebsite.fr', 'http://localhost/mywebsite');

Changer medias url in articles and pages

UPDATE wp_posts
SET post_content = REPLACE (post_content, 'http://mywebsite.fr', 'http://localhost/mywebsite');

Changer meta's url

UPDATE wp_postmeta
SET meta_value = REPLACE (meta_value, 'http://mywebsite.fr', 'http://localhost/mywebsite');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment