Results 1 to 2 of 2
  1. #1
    Join Date
    May 2010
    Location
    Whitchurch, Hampshire, UK
    Posts
    71
    Plugin Contributions
    0

    red flag #1062 - Duplicate entry from Address Book when restoring

    Hi All,

    I'm not sure if this is the right place, but I couldn't find anywhere else for SQL related questions - so here goes.

    I was recently playing around with my prices, and needed to increase all my prices by 20%. However, I accidently increased it by 35% (I copied and pasted an example, and stupidly forgot to change it), so then I tried to play around with the percentages until I got it back to normal - my mathematical skills failed me miserably...

    Thankfully, I made a backup before making these changes, so when it all went t*ts up, I naively thought to myself "Oh, I'll just restore it from the backup then".

    Needless to say, that didn't work. When I import the SQL file that I originally exported as a backup, I get this:

    Code:
    SQL query:
    
    -- -- Dumping data for table `zen_address_book` -- INSERT INTO `zen_address_book` (`address_book_id`, `customers_id`, `entry_gender`, `entry_company`, `entry_firstname`, `entry_lastname`, `entry_street_address`, `entry_suburb`, `entry_postcode`, `entry_city`, `entry_state`, `entry_country_id`, `entry_zone_id`) VALUES (deleted for privacy reasons)[...]
    
    MySQL said: 
    
    #1062 - Duplicate entry '27' for key 1
    Now, entry 27 is the first entry in the Address Book table of the database, which to those who don't know, is the very first table in the ZC database. Not too impressed at this point...
    So, it seems that I can't overwrite the files... Normally, I get the backup done by my web host, who automatically backs up all of it's website every night, and it does it fine.

    Any idea what's going on here? My guess is that it's something to do with permissions? Perhaps it doesn't allow overwriting or something.


    Thanks for any help, as this is a real pain... couldn't have happened at a worse time, as I'm making lots of big changes, and this has practically halted my progress. End of rant.
    The iShop: Make it Yours

    Apple, BlackBerry, HTC, Samsung and Audio Accessories www.the-ishop.co.uk

  2. #2
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: #1062 - Duplicate entry from Address Book

    It's trying to blindly insert data into your already-populated database. So, it's not treating it as a "restore", but rather merely as an "import".

    The tutorial on making backups tells you to include the DROP TABLE directive when making your backups so that a restore will delete all the existing data and tables before recreating them and importing all the old data into the new empty tables: https://www.zen-cart.com/tutorials/i...hp?article=103
    And the tutorial also tells you to export the *database*, not just the tables' data, and include both the structure *and* the data in the export.

    You'll need to manually truncate your existing tables before you can import into them using the data-only export you made.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Replies: 4
    Last Post: 16 Jul 2012, 10:36 PM
  2. Error when importing DB - #1062 - Duplicate entry '1' for key 'PRIMARY'
    By CheapStairParts in forum General Questions
    Replies: 0
    Last Post: 5 Jan 2011, 03:10 AM
  3. SQL Errors when importing to new database - #1062 - Duplicate entry '3' for key 1
    By countingsheep in forum Upgrading from 1.3.x to 1.3.9
    Replies: 3
    Last Post: 17 Sep 2009, 09:43 PM
  4. Replies: 1
    Last Post: 19 Jan 2007, 02:12 AM
  5. Replies: 7
    Last Post: 8 Dec 2006, 11:54 AM

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