Take the 2-minute tour ×

My hosting company wants me to move from a MySQL 4 server to a MySQL 5.5 one. My database is relatively big as my website hosts the data of nearly 200,000+ registered users.

I made an export of all my tables using PHPMyAdmin and I am now trying to import them into the new server. Everything went fine until I tried to import the 'user' table. For information, here is its structure:

`login` varchar(32) NOT NULL DEFAULT '',
`firstname` varchar(255) NOT NULL DEFAULT '',
`lastname` varchar(255) NOT NULL DEFAULT '',
`email` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`login`),
KEY `country_code` (`country_code`)

Nothing spectacular, right? Using the PHPMyAdmin import tab, I uploaded the SQL file. Suddenly, I got the following error:

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

I immediately queried the database and search for a username whom login was 'Jobi'. No match!

I had a look at the query which generated the error and tried to do it manually...

INSERT INTO `ft_user`
  (`login`, `firstname`, `lastname`, `email`, ...)
  ('Jobi', 'Lorem-First', 'Ipsum-Last', 'xxxxx@yyyy.com', ...);

and it worked just fine!

I made the test on my development machine and got the same error. Could someone explain me what I am doing wrong here?

Thank you in advance. Any help is really appreciated.


share|improve this question
Hi Herve, Please check if the country code you are trying to insert, is present in the DB? –  Sashi Kant Jun 12 '12 at 5:47
add comment

1 Answer

up vote 1 down vote accepted

If the input file contains two copies of a record with the same primary key value you could get this error, but then when the transaction gets rolled back that key would no longer exist. Check your input file for duplicates.

share|improve this answer
Ok. Got it ! Another user with login "jobì" was inserted two rows above... How can I make a difference between jobì and jobi for MySQL ? It used to work with MySQL 4. –  Hervé Jun 12 '12 at 6:16
In a bulk upload I don't think you can. You might have to preprocess the data to change one, or make the index non-unique and choose something else (a generated ID) for the primary key and then clean it up after the load. –  Jim Garrison Jun 12 '12 at 6:19
Thanks Jim. I will detect the duplicates and alert users that their login changed –  Hervé Jun 12 '12 at 6:28
add comment

Your Answer


