Posted on 15th January 2010No Responses
Wordpress Error #1062 – Duplicate entry ‘1′ for key ‘id’



I came across this error when I was trying to import an sql file to transfer a wordpress based site. The story is that I bought a site and the seller gave me a dump of the mySQL database for the site. I had to import this to my hosting account. So I created a installation of Wordpress on my hosting account using Fantastico and accessed the specific database for the new site.

 

The process is a bit tricky because you do not want to mess your other databases in the hosting account because that can destroy your other sites !

I thought it will be a simple matter to import the file but as always sql never works without giving errors.

During the import of sql (through phpmyadmin), I kept getting the following error,

 

>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

SQL query:

– Dumping data for table `wp_flickr_post`




INSERT INTO `wp_flickr_post` ( `uid` , `name` , `value` )

VALUES ( 1, ‘commercial_only’, ‘1′ ) , ( 2, ‘legacy_support’, ‘1′ ) ;

MySQL said:

#1062 – Duplicate entry ‘1′ for key ‘id’

>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 

OK so how did I fix this ?

Simple,

Dropped all the tables inside the database so that I had an empty database and nothing else.

Then I tried to import the sql file and it went very smoothly without any problems.

 

So the lesson I learnt was that If I am importing an sql file, especially to setup a new site or to move a site, then I should always remove all the tables within the newly created database and then do a fresh import.

It really helps if you know at least the basic SQL commands because then you will be more confident to troubleshoot. After all the SQL dump of the site that you get in a .sql file is nothing but SQL statements.

As always if you have any question as always leave a message below.




Comments
Leave a Response
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>