For anyone who doesn’t have extensive knowledge of running custom scripts, getting two SQL databases to merge smoothly can be very difficult. Importing fragments of a database in phpMyAdmin, or trying to manually combine databases in a text editor
, is frustrating and time-consuming because the smallest overlap or syntax error between the two databases will corrupt the entire file.
Recently, we had a client who wanted to merge two of their WordPress sites (their current site and older database containing recovered data) together. Both databases had all kinds of custom post types and other fun stuff that was sure to make any attempt at manual combination a huge headache.
The fastest and easiest way to solve this problem is to set up our old database in a fresh install of WordPress, and then use WordPress’ native Import/Export tool.
If the old site isn’t hosted, you’ll need to get it set up and running, either in a subfolder on your server or locally on your computer using MAMP. You’ll want to set up two new installs of WordPress – one to host the old WordPress database you want to import, and the other one an exact copy of your current WordPress site, so you can test importing the data to make sure everything works smoothly.
Don’t have a log in for your old site? In phpMyAdmin, go to wp_users and, if you know which is account was the site’s admin, you can change their password. Click Edit next to their name, type in a new password in the user_pass field and select MD5 from the drop-down menu to the left. Then click the Go button at the bottom of the page.
Install WordPress’ Export tool if asked.
If there are only certain sections you want to export, you may need to make multiple files.
Install the WordPress Import tool if asked.
If everything merges smoothly into the test copy of your WordPress site, then you are free to import the data into your real site.