PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 19, 2022

[FIXED] #1062 - Duplicate entry '1' for key 'PRIMARY'

 January 19, 2022     mysql, phpmyadmin, sql     No comments   

Issue

I am at a complete loss here. I have two databases. One on my localhost site that I use for development and one on my remote site that I use for my live (production) site. I manage both of them through phpMyadmin. As I have been doing for months now, when I need to update the live site, I dump the related database and import the database from my localhost site.

Now, no matter what I try, I keep getting this error:

Error SQL query:

--
-- Dumping data for table `oc_address_type`
--
INSERT INTO  `oc_address_type` (  `address_type_id` ,  `address_type_name` ) 
VALUES ( 1,  'Billing' ) , ( 2,  'Shipping' ) ;

MySQL said: Documentation

#1062 - Duplicate entry '1' for key 'PRIMARY'

I tried creating a new blank database on my localhost and importing into that but same results. I have validated all of the tables and indexes and cannot find anything wrong there.

Any suggestions please as I am completely down until this gets resolved.

By the way, I am completely dropping all tables and importing structure and data. This has always worked until today.


Solution

you need to dump with the drop statements. The table exists and has data already and your trying to insert more which is identical. Im not 100% sure on phpmyadmin but the dumps will have an option for "add drop table" statements



Answered By - exussum
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing