Import post to the database

I am trying to import this SQL file into database. Basically, I had “staging2.new****.com” for development, then moved it to “new***.com” for making live.

But in the process, few wordpress posts from 30th dec to 3rd jan were left out and the old site is not available anymore, just have sql export of these posts.

If I import in database, it says table available, so I removed table created. Then, it says ID is existing, so I removed ID to see if it will auto create, but it does not. Can you help me with this?

  • Huberson
    • Recruit

    Hello Jonathan Millet

    Since the 'wp_posts' table already exist when you setup any WordPress site and probably not empty in your case, executing the queries from the .sql from import might cause the issue.

    If the new site already contain posts and pages I'd suggest using WordPress export option (Tools > Export) to first backup the data. Make sure to export all content instead of just posts since the 'wp_posts' table also contains pages. Then remove the data from 'wp_posts' tables using plain sql query in phpmyadmin or any tools used to manage the database.

    DELETE FROM 'wpmu_posts'

    Once all data removed open the .sql file in a code editor and replace the CREATE line(29) with:

    CREATE TABLE IF NOT EXISTS 'wpmu_posts' (

    and attempt the import again.

    After the post inserted into the database you can then use WordPress importer(Tools > Import) to import the previously exported posts/pages.

    Note that the table is 'wpmu_posts' instead of 'wp_posts', this is because my sandbox site table prefix is 'wpmu_'. You might update that in the .sql file as well before importing.

    If above doesn't work try to manually copy the INSERT query(starting at line 59 to 187 in wp_posts.sql) and manually insert it into the table using the plain SQL options as in first image.

    Regards,

    Huberson

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.