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
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 :)
Re: DB Import Error #1062 - Duplicate entry '1' for key 1
Quote:
Originally Posted by
aushy
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.
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
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.
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.
Re: DB Import Error #1062 - Duplicate entry '1' for key 1
Followed the instructions above and everything imported without errors.
Thanks heaps!