简体   繁体   中英

How do I merge two Wordpress SQL databases in phpmyadmin?

I do not want to manually type in thousands of posts from my old website on the front end of my new website. I simply want to merge the database from the old into the new website in phpmyadmin. I'll tweak the tables to suit the new software afterwards.

  1. I think there are only four tables that need to be merged for my purposes: wp_postmeta, wp_posts, wp_usermeta and wp_users.

  2. The old website is still live, and the most recent post is post_id 28,556. So to be safe and neat, I want all my new website post ids to begin at 30,000.

I found this code which is sort of what I'm looking for, but not really: https://gist.github.com/jazzsequence/99dbee218c1b9a84df0d . This code simply adds +1 to every row, ignoring all associations with usermeta, users, post_ids inside postmeta etc. It cannot be used.

If you are unable to answer the question in it's entirety (it will help thousands of wordpress users if you do it properly), please tell me how to add 30,000 to every value in a given column. eg. If the column is called ID and the existing values are 1,2,4,9,13,24,25,26,28, then they would become 30001,30002,30004,30009,30013,30024,30025,30026,30028.

This might only partially answer the question as it might not allow you to do it manually, but actually I wouldn't recommend it. People already worked on this export - import logic, tested it and wrote plugins for that. I would suggest to use them instead of trying to write it all over again yourself. Just backup your databases and use plugins such as: https://wordpress.org/plugins/wp-exporter/

I would do a google search and find the best export / import plugin that does exactly what you want, there are many of them out there for free.

For the last part of your question, I think

UPDATE `table` SET `ID` = 30000+`ID`

should be enough.

So if you want to combine two MySQL databases in WordPress quickly and easily, then you should read my blog post: 8 Simple Steps to Merge Two WordPress MYSQL Databases

Here, we will stumble upon the eight simple steps that will help you merge two MySQL WordPress databases in a matter of few minutes.

Let's begin the PROCESS:

Step 1: Create Two New WordPress Installs in a Sub-folder.

In case your old site is not hosted, then you need to get it setup and running either in a subfolder on your server or locally on your PC using MAMP. Also, set up two new installs of WordPress for two different purposes:

To host the old WP database that you want to import, and
To create an exact copy of your existing WP site.

Step 2: Log into the database of your old WP site

oldIf you want to log into your old site's database, you need to emulate the following process:

Go to wp_users in phpMy Admin.
Change the password (if you know which account was the site’s admin)
Click Edit next to their name and enter the new password in the user_pass field.
Select the MD5 from the drop-down menu to the left.
And hit  the Go button to get the things done.

Step 3: Install WordPress Export tool

exportInstalling the WordPress export tool is as simple as clicking a button. All you need to do is to go to the Tools, click on the “Export” button, and install WP' export tool. Step 4: Select data and download export file

downloadThis step is all about selecting certain data/sections that you want to export. It may include multiple files. Once selecting the desired files, you'll need to click on Download Export File button.

Step 5: Log into your copy of current WordPress site

Under this step, you need to log into your copy of your current WordPress website.

Step 6: Install the WordPress Import tool

To install WordPress Import tool, you first need to go to the tools in your settings option and click on the Import option. Step 7: Select “WordPress” Step 8: Select the created data file and import it

If everything combines perfectly into the test copy of your WordPress site, you can freely import the data into your actual site.

There is a new plugin : Versionpress ( https://versionpress.com/open-source/ ). You should manually install this plugin in your two wordpress websites. this plugin create a .ini files and it can merge your 2 databases

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM