Questions tagged [mysql-error-1062]

ERROR 1062 (23000): Duplicate entry '%s' for key '%s'

ERROR 1062 (23000): Duplicate entry '%s' for key '%s'

121 questions
3
votes
4 answers

phpmyadmin error "#1062 - Duplicate entry '1' for key 1"

I dropped all tables from a database then restore(import) a backup. Afterwards I am getting error #1062 - Duplicate entry '1' for key 1. Should i repeat the process. Or something else? Why this error is coming?
Jitendra Vyas
  • 134,556
  • 218
  • 544
  • 822
3
votes
3 answers

Error 1062. Duplicate entry in mysql

I have a MySQL table whose schema in which column 1 is primary key. I have a tsv file which I need to insert in this table. Now, the tsv has repetition of primary key hence when I try to insert it in MySQL table it gives an error ERROR 1062…
Saurabh
  • 775
  • 2
  • 10
  • 15
3
votes
1 answer

mysql: Duplicate entry '0' for key 'PRIMARY' and bizarre ID behavior

See log below. (Snipped just for brevity; unsnipped @ http://pastebin.com/k9sCM6Ee) In short: somehow rows are getting assigned ID 0. When this happens, it blocks inserts, even when those inserts aren't actually conflicting with ID 0 (although that…
Sai
  • 6,020
  • 5
  • 36
  • 51
3
votes
3 answers

MySQL: Duplicate Entry for Key 2

I'm not sure what I'm doing to cause this error. The query: INSERT INTO node (type, language, title) VALUES ('bout', 'en', 'the title 3') The error: #1062 - Duplicate entry '0' for key 2 The table: CREATE TABLE `node` ( `nid` int(10) unsigned…
Nick Heiner
  • 108,809
  • 177
  • 454
  • 689
3
votes
1 answer

MySQL error 2006 MySQL server has gone away after upgrade to 5.6.10 using homebrew on Max OS X 10.8.3

I upgraded my installation of MySQL on my Mac OS X 10.8.3 using homebrew brew install mysql Everything seemed to go smoothly, but...not really, as it turns out. I cannot add a new user (neither through the command line nor through phpmyadmin. I…
2
votes
3 answers

INSERT INTO a table with UNIQUE INDEX for two columns

I have a simple tag_map table as CREATE TABLE tag_map ( tag_map_id mediumint(7) unsigned NOT NULL AUTO_INCREMENT, post_id mediumint(7) unsigned REFERENCES posts(post_id), tag_id mediumint(7) unsigned REFERENCES tags(tag_id), UNIQUE INDEX…
Googlebot
  • 13,096
  • 38
  • 113
  • 210
2
votes
1 answer

ORM (RedBean) and duplicate keys

I am currently using RedBean for ORM in my models. I need to insert data into a MySQL table where one of the columns is set to unique. Currently, data is inserted via a form like so: //Create $object = R::dispense('object'); //Need to check if…
F21
  • 28,366
  • 23
  • 91
  • 157
2
votes
1 answer

ERROR 1062 (23000): Duplicate entry 'DP1' for key 'PRIMARY'

I have a table distributor_warehouse which has an auto-incremented coulmn dpID. I cannot insert row after inserting first row. I had seen similar queries like this but everywhere got answers that the column needs to be auto-incremented which is…
2
votes
0 answers

Why am I getting duplicate key integrity errors from Django's get_or_create?

UPDATE: Found the answer here, and the suggested work-around works for me: How do I deal with this race condition in django? Hello all. Observe the following code: while True: User.objects.get_or_create(email='foo-%d@example.com' %…
samtregar
  • 6,276
  • 3
  • 18
  • 16
2
votes
1 answer

parse mysql error msg - is it the right way?

In my php/MySQL code I insert new record into a table (InnoDB) which has many UNIQUE column keys. If insertion fails (with ER_DUP_ENTRY) I need to know which column's value wasn't unique. I was told that to achieve this, you must extract value of %d…
spajak
  • 533
  • 1
  • 6
  • 18
2
votes
1 answer

MySQL strange error in CREATE ... SELECT: ERROR 1062 (23000): Duplicate entry '0' for key 1

This is the problematic query (with the intended meaning: pull all entities paired with entity 530 into a new table, with the count of the pairs): CREATE TEMPORARY TABLE paired ( entity_id INTEGER PRIMARY KEY, numrels INTEGER ) SELECT…
Amadan
  • 169,219
  • 18
  • 195
  • 256
2
votes
2 answers

MySQL: DECLARE CONTINUE HANDLER to continue on errors, printing a warning

I am reviewing / redesigning / refactoring a database and want to create a new database that stores pretty much the same data in a smarter fashion. One of the problems in the 'legacy' database is that it does not make proper use of keys and indices,…
ssc
  • 8,576
  • 8
  • 51
  • 84
2
votes
2 answers

MYSQL BUG: Duplicate entry on Primary/Unique. If I insert word , Word

Hi, I try to INSERT in my database 2 different words with PHP. word <= *is the first* Word <= *is the secound Create Code: CREATE TABLE `myWords_table` ( `myWords` VARCHAR(250) NOT NULL, PRIMARY KEY…
Sebastian
  • 29
  • 9
2
votes
2 answers

How to restore data from MYSQL dump without any duplicate key errors?

Everytime I try restoring the dump, I get : ERROR 1062 (23000) at line 10297: Duplicate entry 'spaß' for key 'PRIMARY' I am trying to restore it using: mysql -u root -ppassword database < 0719.sql
jini
  • 10,563
  • 34
  • 95
  • 166
2
votes
1 answer

IntegrityError when saving user with username=email

I have modified my application, so that when a new user is registered, it's username and email are the same. But when a new user is created, I'm getting IntegrityError : (1062, "Duplicate entry 'my@email.com' for key 'username'"), still the user is…
muntu
  • 1,855
  • 2
  • 17
  • 18
1 2
3
8 9