Forums / Upgrading to 1.5.x / 1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

Views: 14,761

Results 1 to 7 of 7
11 Feb 2013, 11:59 PM
#1
gws76 avatar

gws76

Zen Follower

Join Date:
Apr 2007
Posts:
151
Plugin Contributions:
0

1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

Website with the issue www(dot)sullivanvitamins(dot)com Note the website is down for maintenance.

My hosting company upgraded their PHP on Sunday and when I went to my website on Monday I got many depricated errors as my shopping cart was outdated. I have installed the latest version of Zen Cart 1.5.1 but I'm having trouble accessing store data whether it be categories/products on the main page or in the admin customers/orders. I've tried importing my sql from my backup I did on Monday but get the following errors listed below.

Error

SQL query:

--
-- Dumping data for table `address_format`
--
INSERT INTO `address_format` ( `address_format_id` , `address_format` , `address_summary` )
VALUES ( 1, '$firstname $lastname$cr$streets$cr$city, $postcode$cr$statecomma$country', '$city / $country' ) , ( 2, '$firstname $lastname$cr$streets$cr$city, $state $postcode$cr$country', '$city, $state / $country' ) , ( 3, '$firstname $lastname$cr$streets$cr$city$cr$postcode - $statecomma$country', '$state / $country' ) , ( 4, '$firstname $lastname$cr$streets$cr$city ($postcode)$cr$country', '$postcode / $country' ) , ( 5, '$firstname $lastname$cr$streets$cr$postcode $city$cr$country', '$city / $country' ) , ( 6, '$firstname $lastname$cr$streets$cr$city$cr$state$cr$postcode$cr$country', '$postcode / $country' ) ;

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

Then I tried importing in phpMYADMIN the same file again and I got this error afterwards. What I'm I doing wrong?

Error

SQL query:

-- -- Dumping data for table `address_book` -- INSERT INTO `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 (1, 1, 'm', NULL, '***', '***'', '***'', '', '***'', '***'', '', 223, 12), (2, 2, 'f', NULL, '***'', '***'', '***'', '', '***'', '***'', '', 223, 12), (3, 3, 'm', NULL, '***'', '***'', '***'', '', '***', '***', '', 13, 183), (4, 4, 'f', NULL, '***', '***', '***', '', '***', '***', '', 223, 62), (5, 5, 'm', NULL, '***', '***', '***', '', '***', '***', '', 223, 18), (6, 6, 'f', NULL, '***', '***', '***', '', '***', '***', '', 223, 4), (7, 4, 'f', NULL, '***', '***', '***', '', '***', '***,'[...]

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

http://www.SullivanVitamins.com

America's Favorite Vitamin Source & Irish Shop

12 Feb 2013, 1:28 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

Evidently your backup doesn't contain any "DROP TABLE" statements for the data you're trying to import. Thus it's trying to import duplicates, which are what's triggering the errors.

Either drop all the existing tables manually, or re-export your old data and choose the "Include DROP TABLES IF EXIST" option in the settings.

.
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.

12 Feb 2013, 3:10 AM
#3
gws76 avatar

gws76

Zen Follower

Join Date:
Apr 2007
Posts:
151
Plugin Contributions:
0

Re: 1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

I reinstalled and got "Import has been successfully finished,... " but I don't see any data on either the public or admin side of the website. Is there another step I need to do?

Also, how do you drop existing tables manually?

http://www.SullivanVitamins.com

America's Favorite Vitamin Source & Irish Shop

12 Feb 2013, 6:14 AM
#4
gws76 avatar

gws76

Zen Follower

Join Date:
Apr 2007
Posts:
151
Plugin Contributions:
0

Re: 1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

Sorry for the bump but when I open up the file that was saved today it's considerably smaller 116 kb and the file saved on earlier on the 4th is 4.28 mb and I can see looking through code see orders and product information in the older file save on the 4th. So I need to know how to drop all the existing tables manually to resolve this problem?

Error

SQL query:

-- -- Dumping data for table `address_book` -- INSERT INTO `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 (1, 1, 'm', NULL, '***', '***'', '***'', '', '***'', '***'', '', 223, 12), (2, 2, 'f', NULL, '***'', '***'', '***'', '', '***'', '***'', '', 223, 12), (3, 3, 'm', NULL, '***'', '***'', '***'', '', '***', '***', '', 13, 183), (4, 4, 'f', NULL, '***', '***', '***', '', '***', '***', '', 223, 62), (5, 5, 'm', NULL, '***', '***', '***', '', '***', '***', '', 223, 18), (6, 6, 'f', NULL, '***', '***', '***', '', '***', '***', '', 223, 4), (7, 4, 'f', NULL, '***', '***', '***', '', '***', '***,'[...]

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

http://www.SullivanVitamins.com

America's Favorite Vitamin Source & Irish Shop

12 Feb 2013, 6:28 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

gws76:

Also, how do you drop existing tables manually?
If you are SURE that you know what you're doing, then use phpMyAdmin to mark which tables you wish to DROP and choose DROP from the menu.

But ... honestly, if you're asking that question, then you probably shouldn't be messing with phpMyAdmin. At least not if you don't have numerous confirmed-as-reliable backups.

.
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.

13 Feb 2013, 2:45 AM
#6
gws76 avatar

gws76

Zen Follower

Join Date:
Apr 2007
Posts:
151
Plugin Contributions:
0

Re: 1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

After receiving errors trying to upload database to existing database I decided to create a new database for which I was able to upload my database contents from the 4th to the server and can now see product on the main page. I'm now in the process of trying to upgrade the database and get the following errors.

database upgrade errors listed at the top of page above Zen Cart installer

69 statements processed.
Note: 1 statements ignored. See "upgrade_exceptions" table for additional details.
32 statements processed.
62 statements processed.
Note: 4 statements ignored. See "upgrade_exceptions" table for additional details.
13 statements processed
ATTENTION:  Problems Found
NOTE: Skipped upgrade statements: 5
See details at bottom of page for your inspection.
(Details also logged in the "upgrade_exceptions" table.)
Note: In most cases, these failed statements can be ignored, 
as they are indications that certain settings may have already been set on your site. 
If all the suggested upgrade steps have been completed (no recommendations left), 
you may proceed to Skip Upgrades and continue configuring your site

At the bottom of the page

SKIPPED: Cannot ALTER or INSERT/REPLACE into table linkpoint_api because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot drop index page_accessed on table admin_activity_log because it does not exist.
SKIPPED: Cannot drop index access_date on table admin_activity_log because it does not exist.
SKIPPED: Cannot add index idx_page_accessed_zen to table admin_activity_log because it already exists.
SKIPPED: Cannot add index idx_access_date_zen to table admin_activity_log because it already exists.

http://www.SullivanVitamins.com

America's Favorite Vitamin Source & Irish Shop

13 Feb 2013, 5:35 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 1062 - Duplicate entry '1' for key 'PRIMARY' after importing old database

gws76:

SKIPPED: Cannot ALTER or INSERT/REPLACE into table linkpoint_api because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot drop index page_accessed on table admin_activity_log because it does not exist.
SKIPPED: Cannot drop index access_date on table admin_activity_log because it does not exist.
SKIPPED: Cannot add index idx_page_accessed_zen to table admin_activity_log because it already exists.
SKIPPED: Cannot add index idx_access_date_zen to table admin_activity_log because it already exists.

The first one is because you've apparently not got the Linkpoint payment module activated ... which is unsurprising unless you're actually using them for credit card processing.
The other 4 are a result of your database not needing the cleanup that those statements are intended to do. 
All 5 can be safely ignored.

.
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.