WordPress.org

Ready to get started?Download WordPress

Forums

Importing Posts from Old WP Site Into New Site With SQL Backup File (29 posts)

  1. AnnieSisk
    Member
    Posted 2 years ago #

    Could really use some suggestions here - this is one I've never tried before.

    The old site was built on a really old version of WP with a custom theme. We changed hosting companies, and did a bit of reorganizing of the content. So, instead of importing the old files, I started from scratch with a fresh install of 3.2.1, upgraded to 3.3, and then installed Thesis. From there, I've added the pages and their content, done the initial configurations for the site and Thesis, and now want to get the blog posts imported in.

    But what I've got is a .SQL file, and all the help/codex files seem to suggest that to import this, I need a blank database - which, if I'm understanding this correctly, would require undoing everything I've already done.

    If I went about this backwards, well, I'll take my licks but I'd really rather not have to redo all that.

    Is there any way to cull *just* the posts themselves from a .SQL file and import them into a fresh WP install without deleting everything that's already been set up?

    Many thanks in advance -
    [Signature removed by moderator per forum rules.]

  2. If I were you, what I would do is, set up another WordPress install really quickly using the old database. I would do this on my local machine. It doesn't have to be anything fancy, just install WP, dump your .sql in phpmyadmin, connect to it, that's it. You will probably need to update the db, but that's ok, that won't affect your content.

    Once logged in, I would just export just the posts into an xml file.

    Then I would go to the new site and import them and then delete the one that you just set up.

  3. AnnieSisk
    Member
    Posted 2 years ago #

    That was exactly the idea I came up with after I posted but wanted to make sure there weren't any simpler solutions I was overlooking. Thank you so much!

  4. AnnieSisk
    Member
    Posted 2 years ago #

    I'm really frustrated here. I did the localhost install successfully, finally, and then tried to dump the SQL into the new database. But what happened was it redirected to the client's NEW site.

    I checked the localhost site's wp-config.php file but it was just the way I'd edited it in the localhost install process.

    What's going on? What did I do wrong, or fail to do? Shouldn't it be installing the old site's content into the new localhost site? Why is it redirecting to the active new site URL?

    I should also say this: when I tried to create a new subdomain on my site (dev.anniesisk.com) it ALSO redirected to the client's new site, before I even dumped the SQL backup file into it. I've dumped the cache every time, so that's not it. I just don't understand why, whatever I do, I keep getting routed to the new active site.

  5. AnnieSisk
    Member
    Posted 2 years ago #

    I'm going to start a new thread about this to keep it cleaner. Mods, feel free to delete this and the post above.

  6. manoj skynet
    Member
    Posted 2 years ago #

    probably you are redirecting to the live-site because of following reasons:

    check your local/new database that you have dumped, check for wp_options table, in that table check for the siteurl entry under option_name field, just change that entry according to your local.

  7. AnnieSisk
    Member
    Posted 2 years ago #

    It's localhost:8888/localdev - do I just substitute that for the URL? (I actually tried this before but I must have edited too much because the next time I got a database connection error when I tried to connect.)

  8. manoj skynet
    Member
    Posted 2 years ago #

    what URL are you using to open the index page/home page?? for e. g. http://localhost/myblog, whatever URL you are using to access your index page, you have to insert that URL in DB

  9. AnnieSisk
    Member
    Posted 2 years ago #

    Well, it's Chrome so it strips out the http:// part but yes, http://localhost:8888/localdev. So I put that in where the URL is and we're good... yes? And THANK YOU. This has been bugging the crap out of me for days. :)

  10. Pankaj Pandey
    Member
    Posted 2 years ago #

    Add these two lines to the theme function file, immediately after the initial "<?php" line.

    update_option('siteurl','http://example.com/blog');
    update_option('home','http://example.com/blog');

    Use your own URL instead of example.com, obviously.

    use this plugin http://wordpress.org/extend/plugins/search-and-replace/

    find localhost:8888/localdev and replace with your new url.

    http://codex.wordpress.org/Changing_The_Site_URL

  11. manoj skynet
    Member
    Posted 2 years ago #

    hey, just one more thing, when you follow the Export and Import process, and if you can successfully import your all/selected post to your new server/blog, then please let me know your steps/processes, because i have issues in importing a posts.
    please see at
    http://wordpress.org/support/topic/not-able-to-import-wordpress-posts?replies=1#post-2534256

  12. AnnieSisk
    Member
    Posted 2 years ago #

    Pankaj, you mean functions.php, I'm assuming - in addition to Manoj's suggestion, you mean? Or instead of? My new URL *is* localhost:8888/localdev - I'm getting redirected to the new live site. I'm not sure how this will help, because once I import the database, I get redirected to the new site and can't access the local site, and everything gets replaced with the import file, right?

    Manoj, I'll try! I'm not sure we have the same issues, though.

  13. AnnieSisk
    Member
    Posted 2 years ago #

    OK - I did as Manoj suggested. The only thing I changed was the siteurl as specified. I saved the file again, and then imported it in PHPMyAdmin. Before, when I imported the SQL file, it went perfectly (although I had the redirect issue). Now, I'm getting the following error:

    Error
    SQL query:
    
    # WordPress MySQL database backup
    #
    # Generated: Wednesday 28. December 2011 09:47 CST
    # Hostname: localhost
    # Database: <code>kevinhic_wrdp1</code>
    # --------------------------------------------------------
    # --------------------------------------------------------
    # Table: <code>wp_categories</code>
    # --------------------------------------------------------
    #
    # Delete any existing table <code>wp_categories</code>
    #
    DROP TABLE IF EXISTS  <code>wp_categories</code> ;
    
    MySQL said: 
    
    #1046 - No database selected

    But I haven't changed anything in that line, so I don't know what the problem is now.

    EDITED TO ADD: Does it have anything to do with the database name? It's calling the old database but my localhost db is named 'localdev.' Not sure if that means anything.

  14. manoj skynet
    Member
    Posted 2 years ago #

    this is because you have not selected any database.

    first you need to create one database, and then in that empty database you need to import

  15. AnnieSisk
    Member
    Posted 2 years ago #

    EDITED: I created a new database and successfully imported the revised SQL file (edited the siteurl to http://localhost:8888/localdev per your instructions earlier). I pulled up the WP site and dashboard - it's a nice blank WP with the default theme but there are no posts. How do I access the imported posts so I can export them to XML, which was the whole reason I started this process in the first place, LOL?

  16. manoj skynet
    Member
    Posted 2 years ago #

    i mean yes, in your localdev database, one which supporting your local version of WP, in that DB import,

    error may be because of you have not selected your localdev database and you are trying to import

  17. AnnieSisk
    Member
    Posted 2 years ago #

    How do you create a database in a database with MAMP?

  18. AnnieSisk
    Member
    Posted 2 years ago #

    Or how do I select the localdev database in MAMP before import? I'm not seeing any other alternative on MAMP to do this. I can create a table in localdev, of course. I can create a blank database within localhost and import the file there. I can't see any mechanism to select localdev and then import, without importing it INTO localdev. Sorry I'm so dense here but I am lost. Very grateful for your help.

  19. Pankaj Pandey
    Member
    Posted 2 years ago #

    follow simple steps that work every time for me

    1. export your database
    2. copy your wp-content folder to server
    3. import your data backup to new server make sure wp-config.php have correct info
    4. update your theme function file as suggested at previous post.

    you can access your site after these post. after that you need to find replace in all post as post save image url in post table.

    I hope it work for you

  20. manoj skynet
    Member
    Posted 2 years ago #

    i think now you end-up with two databases,
    one for your local wordpress, and another into which you have imported the data right?

  21. AnnieSisk
    Member
    Posted 2 years ago #

    Pankaj, it may be simple, but it isn't working for me. I don't know what to tell you. I've been all over these boards, looking for help, and even looking for someone to help me for compensation in job boards and I'm stuck with a very pretty blank WordPress install, a backup file that I cannot successfully import, and a client who's looking for his posts.

    If I try to import the backup file into the localdev database, I get the above error message. If I import the backup file into another database, I get a clean import but don't know how to access the files because that database isn't linked in any way that I can tell to the local WP install. So I can't get past your step 3.

    Manoj, yes, exactly - but how do I access the posts? All I need are the posts in XML format which I can then import into the client's live site.

  22. manoj skynet
    Member
    Posted 2 years ago #

    do simple thing,

    use only one DB,
    one which you using for your local wordpress.

    import all you data into that DB, not in other/new DB

    then only you will be able to see all the post

  23. AnnieSisk
    Member
    Posted 2 years ago #

    Except as I said, when I do that, I get the error message. Hence, my frustration, and I'm sure yours and Pankaj's, too. ;)

  24. Pankaj Pandey
    Member
    Posted 2 years ago #

    if your problem not solve till yet. contact me out of forum i will fis this issue in 10 min. I know forum moderator does not like my comment and may be delete this comment. still i want to solve ur problem in 10 min. as u already spend 2 days with no solution.

    if you still want to learn to fix continue posting ur issue. if you want to fix this issue instant contact me.

  25. AnnieSisk
    Member
    Posted 2 years ago #

    Gotcha. I already posted a jobs entry on the Jobs board. If you can handle it, so much the better.

  26. Pankaj Pandey
    Member
    Posted 2 years ago #

    Did you upload wp-content on server?

  27. AnnieSisk
    Member
    Posted 2 years ago #

    It's a local install, and I don't have any access to the old blog's stuff except for this SQL file.

  28. Pankaj Pandey
    Member
    Posted 2 years ago #

    you developed this on local. also you want to host at local server?

    can you explain what apache you are using?

  29. AnnieSisk
    Member
    Posted 2 years ago #

    OK, let me explain the scenario a little bit better - this has been sort of scattered all over these boards in multiple threads, I realize, and it might be confusing to some coming in on this thread.

    Originally, I was hired to upgrade this guy's blog/site. He was running WP 2.1.4. I backed up the files - hence the SQL file I have now. I also copied the text from his pages into a Word file. I tried to install an export plugin to get the posts in XML format but that didn't work - the servers required, but wouldn't accept, the FTP credentials. Then when I tried to upgrade, we ran in to many other difficulties -- upshot of all that was that we discovered the hosting company (a local group to the client) hadn't upgraded the servers and had set things up in such a way that upgrade was going to be a nightmare.

    So client agreed that he needed a better hosting company and on my recommendation went with Hostgator. Client then asked me to move the blog. I did that successfully - set up the new site, put all his pages back up from the Word document copy I'd made earlier, installed Thesis, set it up for him, made it look pretty, etc. -- basically did a ton of work. Then I realized there was a problem with getting the blog posts imported in, because I didn't have the XML version - but by this point, the old site was gone and is no longer accessible.

    As I was advised here, I set up a subdomain on my site to load up the new database and export the posts to XML, so I can take the XML file to client's new site and import them. That didn't work and I know why, now (because the siteurl was still pointing to client's old URL).

    On the basis of further advice here, I set up the localdev install ... and that's where you came in to the story, with the redirect to the client's old URL, the database SQL import error, etc.

    So as you see - my ultimate goal is to take the SQL file and from it "extract" an XML file of the 200 posts he's written over the last 5 years so I can take the XML file and import it into the client's NEW site. The localdev site is just a means to the end of the XML file.

    Does that make more sense?

Topic Closed

This topic has been closed to new replies.

About this Topic