Link to home
Start Free TrialLog in
Avatar of ak010
ak010

asked on

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

Hello,

I'm running XAMPP on Windows locally. Trying to import a large SQL file into MySQLwith content I am not familiar with, using phpMyAdmin (doing a demo). The error message I'm getting is: #1062 - Duplicate entry '1' for key 'PRIMARY'.

When I attempt the same on my hosting server, the error message is #1062 - Duplicate entry '1' for key '1'. "Do not use AUTO_INCREMENT for zero values" is checked by default on the web hosting server.

phpMyAdmin that I'm using locally is an older version and the option "Do not use AUTO_INCREMENT for zero values" is not available.

I would greatly appreciate any help.
Avatar of G_H
G_H
Flag of United Kingdom of Great Britain and Northern Ireland image

This usually happens when importing data (as you are), or if you have a badly formed insert statement.

Basically, it is telling you that you are trying to insert a row, with a value for the primary key field, which has already been used. Let use an example:

 
ID (PK) Location
1       United Kingdom
2       United States
3       Peru
4       Fiji
5       Maldives

Open in new window


Now lets say you try to insert another row:

 
INSERT INTO Table ID=3, Location='Iraq'

Open in new window


...As the key has already been used, you will be warned that you are trying to add a duplicate entry.

The solution here will be to take a look at your data, and see exactly what you are trying to import. Can you please give us the table structure, and two line of data for your table.

GH
Avatar of ak010
ak010

ASKER

GH,

Thank you for your response. Here is the table structure and the two lines of data as requested.

AK010 db-error.txt
ASKER CERTIFIED SOLUTION
Avatar of G_H
G_H
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial