Reputation: 71
I am not sure why I am getting this error #1062 - Duplicate entry '1' for key 1 cany any one help explain what it means. Thanks
Upvotes: 6
Views: 65450
Reputation: 179
The problem is related with your file - you are trying to create a DB using a copy - at the top of your file you will find something like this:
CREATE DATABASE IF NOT EXISTS *THE_NAME_OF_YOUR_DB*
DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci;
USE *THE_NAME_OF_YOUR_DB*
;
and I'm sure that you already have a DB with this name - IN THE SAME SERVER - please check.
Upvotes: 1
Reputation: 1
You need to add primary key with the group in which one primary key must be unique value. e.g. if a table has 4 columns id, name, address, group_id where group_id has duplicate value , if I want to add group_id as primary then that should be in a group consist with id and group_id
Upvotes: 0
Reputation: 703
I think you're trying to insert '1' to a unique key field that already has a '1' value
Upvotes: 2
Reputation: 449395
You are probably trying to insert a record with the ID (or some other field) 1
set, while such a record already exists in the table. The field that is the primary key must have a unique value for each record.
Upvotes: 4
Reputation: 2423
More than likely your column is set to be Unique, and you're trying to input a row with an ID that already exists in your table.
Upvotes: 6