Ask your WordPress questions! Pay money and get answers fast! (more info)

Export post table from one Database to a another Database WordPress

Basically I have a version of a site in development. That site when live and all i have from the clients old site is their previous database.

The live site is missing 100 ish posts from before. I've exported the old sites entire posts table, but when I try to import it into the dev site DB via phpAdmin, it gives me a " Duplicate entry '874' for key 'PRIMARY'

Answers (3)

2015-06-15

MJ answers:

Sounds like one or more of your posts have the same Primary Key (or ID, which should be unique for each post) in the database. How are you doing the export and import? Have you tried the official WordPress importer? [[LINK href="https://wordpress.org/plugins/wordpress-importer/"]][[/LINK]]

There is also a guide here: http://www.elegantthemes.com/blog/tips-tricks/import-export-wordpress-website

Let me know if that helps.


Rory Heaney comments:

I only have the db from the previous site. I have a dev version of the new site I want to import those posts into to make sure everything is good to go. Then I would just use the wordpress importer/exporter


MJ comments:

Definitely. You'll save yourself a lot of pain if you create a temporary WordPress site with only your old db, then use the WordPress import/export to export that, and finally import the file to the target database.

I would <strong>not</strong> drop tables unless you have complete knowledge of the WordPress database structure. For one thing the primary key for posts needs to match in other tables where the data is related. So for example if you only "fix" the posts table you will end up breaking things like the post meta data which includes info on everything from attached files to thumbnails to oembeds to plugin and 3rd party custom data etc. This is why there is an import/export tool, because it takes care of all these things for you.

2015-06-15

Navjot Singh answers:

If you are going to import the complete posts table from the dev site, then you might want to drop the posts table from the new site first to avoid duplicity and errors like the one you got above.

Also the best way of doing it as suggested by MJ would be to use the official [[LINK href="https://wordpress.org/plugins/wordpress-importer/"]]WordPress Importer[[/LINK]]. Just select the posts and export and import them on the new site.


Rory Heaney comments:

I would prefer to test on the dev site. Would you suggest dropping the table form the dev site (i have the db from the OLD site, that contains the posts I need)


Navjot Singh comments:

If you haven't added any other content in the dev site then I suggest take a backup first of the dev site, then drop the posts table from it and try importing the posts table from the old site which has all the posts.


Navjot Singh comments:

Another simpler non mysql way to be to use the old sites db to create a temp site, use the exporter to export all those posts, delete all posts from dev site and then import.

2015-06-16

Arnav Joy answers:

so only posts are missing or categories and attachments are also missing ?