MyBB Community Forums

Full Version: SQL 1062 Error duplicate Entry (with workaround)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have encountered an issue similar to this one:
http://community.mybb.com/post-687845.html

This is triggered by phpBB3 user names which are similar, but have different letter variations, for instance: "René" and "Rene".

My instance of phpBB uses utf8_bin as collation:
show create table phpbb3_users;
  `username` varchar(255) collate utf8_bin NOT NULL default '',

While MyBB uses utf8 as collation:
show create table mybb_users;
 /*!40101 SET character_set_client = utf8 */;
 CREATE TABLE `mybb_users` (
   `uid` int(10) unsigned NOT NULL auto_increment,
  `username` varchar(120) NOT NULL default '',

So I did the following change before triggering the merge :

 diff -u mybb-0[12]*
--- mybb-01-after-install.dump	2012-07-31 13:49:45.000000000 +0200
+++ mybb-02-encoding.dump	2012-07-31 14:04:55.000000000 +0200
@@ -2084,7 +2084,7 @@
 /*!40101 SET character_set_client = utf8 */;
 CREATE TABLE `mybb_users` (
   `uid` int(10) unsigned NOT NULL auto_increment,
-  `username` varchar(120) NOT NULL default '',
+  `username` varchar(120) collate utf8_bin NOT NULL default '',
   `password` varchar(120) NOT NULL default '',
   `salt` varchar(10) NOT NULL default '',
   `loginkey` varchar(50) NOT NULL default '',

The error doesn't occur anymore, and the import is then successful, but I am wondering:
  1. Is this specific to my case ?
  2. Will my solution have bad side effects in the long term ?
  3. Any recommendation for a clean solution ?

Thanks !

Olivier
I'm having this issue but im merging vB....

here is the error im getting


SQL Error:
1062 - Duplicate entry '' for key 'loginname'
Query:
INSERT INTO mybb_users
(`usergroup`,`additionalgroups`,`displaygroup`,`import_usergroup`,`import_additionalgroups`,`import_displaygroup`,`import_uid`,`username`,`password`,`salt`,`loginkey`,`email`,`regdate`,`lastactive`,`lastvisit`,`website`,`showsigs`,`signature`,`showavatars`,`timezone`,`avatardimensions`,`avatartype`,`avatar`,`lastpost`,`icq`,`aim`,`yahoo`,`msn`,`hideemail`,`allownotices`,`regip`,`lastip`,`longregip`,`longlastip`,`language`,`passwordconvert`,`passwordconverttype`,`postnum`,`invisible`,`birthday`,`birthdayprivacy`,`subscriptionmethod`,`receivepms`,`receivefrombuddy`,`pmnotice`,`pmnotify`,`showquickreply`,`ppp`,`tpp`,`daysprune`,`timeformat`,`dst`,`buddylist`,`ignorelist`,`style`,`away`,`awaydate`,`returndate`,`referrer`,`referrals`,`reputation`,`timeonline`,`showcodebuttons`,`totalpms`,`unreadpms`,`pmfolders`,`notepad`,`threadmode`,`showredirect`,`dateformat`,`dstcorrection`,`warningpoints`,`moderateposts`,`moderationtime`,`suspendposting`,`suspensiontime`,`suspendsignature`,`suspendsigtime`,`coppauser`,`classicpostbit`,`loginattempts`,`failedlogin`,`usernotes`,`passwordconvertsalt`) VALUES ('2','','2','','','2','4','hitmun','','','0','','1135187700','1303766882','1303766882','','1','[url=http://www.devclothes.com][SIGPIC][/SIGPIC] [/url]','1','','','','','1296863608','','','','','1','1','','','0','0','','48219dfc99dbca5847447c7ee13d7906','vb3','0','0','10-26-0000','all','2','1','0','1','1','1','0','0','0','0','0','','','0','0','0','0','1','0','0','0','1','55','0','1**Inbox$%%$2**Sent Items$%%$3**Drafts$%%$4**Trash Can','','','1','0','1','0','0','0','0','0','0','0','0','0','0','0','','[o-') 
Found this error too, converting from phpbb3.
Had two different users: "Tomás" and "tomas".