WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Table 'wp_categories' already exists Error (7 posts)

  1. misty9
    Member
    Posted 6 years ago #

    I've got the following error while trying to import an exported database SQL fIle:

    #1050 - Table 'wp_categories' already exists

    Given that WordPress has been installed, I would expect table wp_categories to be there prior to importing the database file. Could someone help me with the following questions?

    1. Why do I get this error?
    2. How can I import the SQL file without compromising the existing data in wp_categories?

    Thanks.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    1. Why do I get this error?

    Because you're trying to import an existing set of data into another existing set of data. You can't merge stuff this way.

    2. How can I import the SQL file without compromising the existing data in wp_categories?

    You can't. Don't do that.

    If you want to bring stuff in from another blog, use the Export and Import functionality in WordPress, not using SQL and other tools.

  3. misty9
    Member
    Posted 6 years ago #

    I am importing an exported SQL file from exact the same database and same blog.

    I certainly expect wp_categories table to be there. What I don't understand is why WordPress can NOT simply update the table?

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    I am importing an exported SQL file from exact the same database and same blog.

    Have you added or deleted stuff to that blog in the meantime? Does the data already in the database conflict with data that is in the SQL file?

    The reason you're getting the error in question is because your exported SQL file has the statements in it to create the database *from scratch*. It's a backup. When the table is already there, it has a problem with that. You're trying to restore a backup (designed for creating the whole thing) into an existing database (which thinks that it is the whole thing). That's not going to work properly.

    You really shouldn't mess with SQL files if you don't understand databases. The main thing you're going to accomplish is to break your site. Badly.

    I certainly expect wp_categories table to be there. What I don't understand is why WordPress can NOT simply update the table?

    This has nothing to do with WordPress. You're doing straight SQL, bypassing WordPress altogether.

  5. misty9
    Member
    Posted 6 years ago #

    The reason for importing the database is that I had erased some content of a given post by error. I want to get back the original content that saved in the exported file a couple weeks prior to the accident.

    Yeah, sorry. it is SQL, not WordPress.

    I don't like to mess with data in the database either.

    What are suggested methods for restoring saved data then?

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    If it's only for one post, then open up the SQL file in a text editor, find that post content, then copy and save it into the post in WordPress.

    SQL is just text, you can look through it to find your content without too much difficulty.

  7. misty9
    Member
    Posted 6 years ago #

    It's just one paragraph. Thanks for the idea, which works for me without messing up other data.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.