Recently I was asked by a client to pickup hosting and maintenance on an existing Drupal 6 site. The previous hosting company gave me a backup of the files and a SQL export from the database. The SQL export was performed from within the database, so I had to first create a blank database. I almost exclusively use phpMyAdmin for any MySQL tasks, so this solution will reflect that method.
After creating the blank database on the server, I clicked on the database name then clicked the import tab. I browsed to the file, made sure the SQL format type was selected and clicked Go. After several minutes MySQL kicked back and error that looked something like this (I shorted the error at the ellipsis):
Error
SQL query:
INSERT INTO `users` VALUES (0,'','','',0,0,0,'','',0,0,0,0,NULL,'','','',NULL,'',1),(1,'siteadmin' …
#1062 - Duplicate entry '1' for key 1
After some research I learned that the auto increment setting on the users table UID field was the cause. Some more research and some trial and error, I realized I needed to change the uid field settings in my exported SQL file for the users table from this:
`uid` int(10) unsigned NOT NULL auto_increment,
To this:
`uid` int(10) unsigned NOT NULL default '0',