Getting WordPress images into the Media Library after migration

Solution:

You do not need the export the wp_post data or wp_postmeta.

Here’s how I migrate my websites manually:

  1. Export the whole database and download the files.
  2. Import the whole database and copy the files on the root folder.
  3. Then on your phpmyadmin and run these scripts, select wp_options table:UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldurl‘, ‘http://www.newurl‘) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
    1. On the wp_posts table run these:

    UPDATE wp_posts SET guid = replace(guid, ‘http://www.oldurl‘,’http://www.newurl‘);

    UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.oldurl‘, ‘http://www.newurl‘);

    1. On wp_postmeta table run this:

    UPDATE wp_postmeta SET meta_value = replace(meta_value,’http://www.oldurl‘,’http://www.newurl‘);

Make sure to change the urls. This will fix the images and other media that are not showing because the url is broken or your site is showing the old url.