How do I merge two Wordpress SQL databases in phpmyadmin? - mysql

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.
I think there are only four tables that need to be merged for my purposes: wp_postmeta, wp_posts, wp_usermeta and wp_users.
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

Related

Search and Replace in PHPMyAdmin database for Wordpress (absolute beginner)

I apologise in advance for I know that this question has been asked several times already, but being a complete beginner at wordpress coding and database handling, I am still not sure about what those answers really meant.
So having just coded a website and converted it into WordPress, I now find myself having to change all of the localhost strings to the accurate ones, but with hundreds to go through, I just wanted to know if any of you were able to recommend a program or technique within PHPMyAdmin (that I may not be aware of) to avoid having to change them one at a time.
Thank you all in advance for your time and attention.
First, let me start by saying this is very dangerous, especially for an absolute beginner such as yourself. Please use this with extreme caution as you can potentially bring the entire site down by replacing values in your database with the wrong data.
With that said, there is a script specifically designed for doing search and replace on the WordPress MySQL database. http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Here's the direct download link: https://github.com/interconnectit/Search-Replace-DB/archive/master.zip
You will extract the folder from the donwloaded zip, then upload the folder to the root of your WordPress install. Once its uploaded just reference the folder in the browser. I always rename the folder to sr (shorthand for search and replace) so its easier to write out the full URL. So as an example, once its in the root of the WordPress install you'd access it like www.example.com/sr/.
After you access the script in the browser, you'll have a GUI with two boxes at the top. The first you'll enter the string you're searching for, and the replace string goes in the second box. Your MySQL details/login should already be populated. After entering your S&R terms scroll down and click "Update Details", then do the "Dry Run" option first. It'll run through the database and show you the values that will be changed. If you are satisfied with the changes, click "Live Run".
Depending on the database size it'll take just a short time to complete. This is the easiest way to S&R the WordPress database.
Important: for security reasons you'll want to delete this folder from your server after you have finished using it. You don't want a database S&R utility just lingering around for no reason.
Another possible option if you're familiar with WP-CLI is to use the wp search-replace command: https://developer.wordpress.org/cli/commands/search-replace/ This would be done through Terminal or another command line utility.
In phpMyAdmin open your table, choose Search > Find and replace. Then specify in which column you want to find and replace, and the original and replacement texts.
Without any doubt I would use http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
This tool is especially designed for the situation you describe.
You upload the code to your server and then enter the "find" and "replace"
You can then do a dry run and the system will show you all the replaces that will be made across every single table in your Wordpress database.
Once you're happy then you can do a live run and the changes are made.
I have used this on probably one hundred Wordpress sites and it works a charm.

Migrating From a Combined Hand Crafted Website and WordPress to Only WordPress

I've migrated a hand crafted website to WordPress website. The previous implementation did have WordPress in a sub directory for a blog. Apparently the admin for the blog was not the owner of the website, I couldn't get the admin username and password from the owner so I couldn't use the duplicator plugin. Due to time constriction I was not able to merge the blog into the new website prior to removing the active blog.
I have all the files and the database (in database.sql form) from the previous version of the website.
I have found the database table diagram at Codex, but I'm most interested in the minimal number of tables necessary to transfer.
What tables from the old database do I need to import into the new database (after changing all the absolute links to the correct addresses)?
I know about the wp_postmeta table and wp_posts table, are there any others I need to import.
It depends on what data you want to preserve.
The main data types and tables are:
Terms (wp_term_relationships, wp_term_taxonomy, wp_termmeta, wp_terms)
Comments (wp_comments, wp_commentmeta)
Users (wp_users, wp_usermeta)
Do you not want to just import the whole .sql file and start from there? That might be easier than trying to piece things together. You could then drop any table than doesn't being with wp_ (or whatever prefix you used).

Exporting Database Using phpMyAdmin

I'm attempting to switch from Third-Party Hosting to In House hosting. I have all sites but one transferred. The last one I'm having issues with involves some plugins. I'm asking the plugin programmer for a new download, and was told that I have to export the database.
My question is: is there a way to export every concept of the database including Column Headers. I'm wanting to export the whole database, so when I import it into my SQL Server I don't have to do anything, just go into WordPress import the setups for it.
If you already have access to your current database phpMyAdmin
Log in to it
Select the desired database from the left menu
You should see an Export tab in the right panel, click it
In Export Method you can leave it as Quick
Export it as SQL
Press GO (the submit button)
If you happen to have any problem downloading the export, try using the custom method and selecting one compression (gzipped for example) method.
Then, importing the database is the inverse process into your new Database.
Login to your new database phpMyAdmin
Select your newly created DB
Click Import tab
Select the file to upload
Go
Make sure your new database is EMPTY if you want to migrate ALL THE TABLES. If you want to just migrate a few tables, you can select them in the custom method and then import only those.
Make sure you are running the same Wordpress files with your DB data, or you may experience many inconsistencies.
The primary issue was fixed with a new download of the plugin.

MySQL data transfer/update to another database

I have a forum which is here or http://neue.st/index.php
and I want to transfer the data from that forum to a new forum in a different directory http://neue.st/forums
I also only want to have select pieces of data to be transfered such as users, posts, topics, forums but not things like themes & mods
I am doing this because I kinda of screwed up the data for mods & themes for the original forum & have no idea how to reverse it because I forgot to do the backuping
Is there anyway to do this with phpmyadmin
A good tool to use... but not absolutely necessary is PMA (phpMyAdmin). You should log in, click on the database you want to export data from and then click the export button.
You can see there is a "custom" choice, upon selecting that you will be presented with more options including the ability to choose which tables you need to export.
After that, head on over to your other database and import the SQL file that was generated/downloaded and happy days.
you can use SQLYog community edition, it is easy to select what ever data you want to export.
If you download the Support toolkit from phpBB you are able to 'clean' the database of all non standard tables and rows (i.e. things added by MODs), leaving you with a clean database.
For themes that you no longer need, you can delete and uninstall these via your Admin control panel before removing them from your server.
If you just use 'selected' parts of your database then chances are it won't work properly because there are so many relationships between the different tables.

Can a separate WordPress (same server) get posts from an existing one, but have different settings?

When developing WordPress themes for a site with a large amount of posts, how can I dynamically pull existing post data from the live version of the site onto my testing site? I already know about WordPress's export feature, but that's one-and-done, not dynamically queried.
Plan A:
Proposed Solution:
Create read-only user in live site's database
PRECAUTION: change test site's prefix from "wp_" to "test_"
Problems:
Settings (like current theme) on test site cannot be changed, thanks to read-only user
No posts found in "test_posts", even though I'd like it to search "wp_posts"
Is there an easier way or existing solution to avoid rewriting WordPress system files on the test site? I'd really rather not rewrite WordPress's database interface...
Similar: Linking themes across WP installations
just duplicate the DB, re-name and call DB in wp-config!