Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2011
    Posts
    5
    Plugin Contributions
    0

    Default DB Import Error #1062 - Duplicate entry '1' for key 1

    Hi,
    I was trying to install a new template when I accidentally installed the wrong SQL file.. basically all the products in my store were overwritten with the demo products and categories. I did do a database backup beforehand, however now I have a problem. When I go to import the database, it comes up with an error.

    SQL query:

    -- -- Dumping data for table `address_book` -- INSERT INTO `address_book` ..(continues to list data in the address book)

    MySQL said:
    #1062 - Duplicate entry '1' for key 1

    How can I fix this? I really really really don't want to enter all my products again.

    Edit:
    v1.3.9h

  2. #2
    Join Date
    Jan 2011
    Posts
    5
    Plugin Contributions
    0

    Default Re: DB Import Error #1062 - Duplicate entry '1' for key 1

    I have a feeling I may have posted this in the wrong section.. pretty sure my site is hosted on a linux server. If a mod could move this to the appropriate section it would be great :)

  3. #3
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: DB Import Error #1062 - Duplicate entry '1' for key 1

    Quote Originally Posted by aushy View Post
    MySQL said:
    #1062 - Duplicate entry '1' for key 1

    How can I fix this? I really really really don't want to enter all my products again.
    You'll need to DROP the table (or contents) before importing your backup.

    If you use phpyadmin to create your backups, the next time you do so ensure you check the box that reads:
    Add DROP TABLE statement

    Cheers
    Rod

    ps. Don't drop the Database itself, just the tables and/or contents. I tend to drop the contents JUST IN CASE the 'create table if not exists' option hasn't been checked either.

  4. #4
    Join Date
    Jan 2011
    Posts
    5
    Plugin Contributions
    0

    Default Re: DB Import Error #1062 - Duplicate entry '1' for key 1

    I am pretty sure the create table if not exists box was checked, because that is the default. The only box not checked by default is the drop table.

    So how I go about manually dropping the table? Or maybe just to be safe, how do I only drop the table contents?

    Thanks

  5. #5
    Join Date
    Jan 2011
    Posts
    5
    Plugin Contributions
    0

    Default Re: DB Import Error #1062 - Duplicate entry '1' for key 1

    Let me use the table "address_book" as an example.

    In phpmyadmin, I select my zen cart database from the drop down list on the left hand side. I then select "address_book" on the left, and also select "structure" from the top menu, upon which I am presented with a table. Under the columns heading, shows:

    address_book_id
    customers_id
    entry_gender

    Each one of these has 'drop' at the end of the line. If I drop these, is this dropping an entire table, or dropping the table contents? I think dropping the table contents is the smartest option for me to try first, as suggested above.

  6. #6
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: DB Import Error #1062 - Duplicate entry '1' for key 1

    In phpMyAdmin, once you have selected your database then scroll to page bottom on the right.

    There you will see a link for "Check All". Clicking the link will select all Tables.
    To the right of that link you will see a drop-down menu showing "With selected". Choose "Drop" then press the "Go" button; bottom right.

    You have now removed all previous Tables whilst still retaining your Database. You should now be able to Import your previous database.

  7. #7
    Join Date
    Jan 2011
    Posts
    5
    Plugin Contributions
    0

    Default Re: DB Import Error #1062 - Duplicate entry '1' for key 1

    Followed the instructions above and everything imported without errors.

    Thanks heaps!

 

 

Similar Threads

  1. Replies: 37
    Last Post: 7 Jul 2008, 07:17 PM
  2. 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a
    By Ellume in forum Upgrading from 1.3.x to 1.3.9
    Replies: 24
    Last Post: 10 Jun 2008, 07:34 AM
  3. Error: 1062 Duplicate entry '0-78' for key 1
    By G33K-Chik in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 15 Apr 2008, 08:47 PM
  4. SQL Error : 1062 Duplicate entry '0' for key 1
    By Wazoo in forum General Questions
    Replies: 3
    Last Post: 3 May 2007, 02:50 PM
  5. Replies: 2
    Last Post: 20 Oct 2006, 09:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR