How do I fix the MySQL exception: "Duplicate entry '12345' for key 1 - FogBugz Knowledge Exchange most recent 30 from http://fogbugz.stackexchange.com2013-05-19T02:44:38Zhttp://fogbugz.stackexchange.com/feeds/question/5629http://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://fogbugz.stackexchange.com/questions/5629/how-do-i-fix-the-mysql-exception-duplicate-entry-12345-for-key-1How do I fix the MySQL exception: "Duplicate entry '12345' for key 1 Rob Sobers2010-10-29T14:15:08Z2010-11-01T09:39:12Z
<p>I was trying to upgrade FogBugz, and during the database migration I got the following MySQL exception:</p>
<pre><code>MySql.Data.MySqlClient.MySqlException: Duplicate entry '12345' for key 1
w
System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) w
System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) w
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) w
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows) w
Wasabi.Runtime.ADO.KeySetCursor.Update() w
c:\src\Wasabi\Wasabi.Runtime\ADO\Cursor.cs:wiersz 440 w
Wasabi.Runtime.ADO.RecordSet.Update() w
c:\src\Wasabi\Wasabi.Runtime\ADO\RecordSet.cs:wiersz 160 w
FogCreek.FogBugz.__Global.UpdateRS(RecordSet rs, Nullable1
nCacheClearLevel) w
c:\src\FogBugz\distribution\src-Website\util.was:wiersz 3585 w
FogCreek.FogBugz.CRevision.Commit(CacheClear nCacheClearLevel) w
c:\src\FogBugz\distribution\src-Website\_Generated.was:wiersz 38640 w
FogCreek.FogBugz.CRevision.Commit() w
c:\src\FogBugz\distribution\src-Website\_Generated.was:wiersz 38604 w
FogCreek.FogBugz.CRevision.Save(IDiffable oDiffable, Boolean fWikiPage,
String sCommentInit) w
c:\src\FogBugz\distribution\src-Website\CRevision.was:wiersz 152 w
FogCreek.FogBugz.CTemplate.ActiveRecord_BeforeCommit() w
c:\src\FogBugz\distribution\src-Website\CTemplate.was:wiersz 777 w
FogCreek.FogBugz.CTemplate.Commit(CacheClear nCacheClearLevel) w
c:\src\FogBugz\distribution\src-Website\_Generated.was:wiersz 44209 w
FogCreek.FogBugz.CTemplate.Commit() w
c:\src\FogBugz\distribution\src-Website\_Generated.was:wiersz 44196 w
FogCreek.FogBugz.CSchema.UpdateDefaultTemplate() w
c:\src\FogBugz\distribution\src-Website\CSchema.was:wiersz 2611 w
FogCreek.FogBugz.CSchema.FinalUpdates(Int32 oldVersion) w
c:\src\FogBugz\distribution\src-Website\CSchema.was:wiersz 2465 w
FogCreek.FogBugz.CSchema.UpdateDB(Int32 OldVersion, Boolean bForce) w
c:\src\FogBugz\distribution\src-Website\CSchema.was:wiersz 137 w
FogCreek.FogBugz.__Global.UpgradeDatabaseVersion(Boolean fForce) w
c:\src\FogBugz\distribution\src-Website\dbUpgrade.was:wiersz 287 w
FogCreek.FogBugz.__Global.UpgradeWithRollback(Boolean fForce) w
c:\src\FogBugz\distribution\src-Website\dbUpgrade.was:wiersz 240
</code></pre>
http://fogbugz.stackexchange.com/questions/5629/how-do-i-fix-the-mysql-exception-duplicate-entry-12345-for-key-1/5630#5630Answer by Rob Sobers for How do I fix the MySQL exception: "Duplicate entry '12345' for key 1 Rob Sobers2010-10-29T14:18:31Z2010-10-29T14:18:31Z<p>This is a problem at the MySQL database level. The table that FogBugz was trying to write to is likely crashed or corrupted.</p>
<p>Look in the error message for the affected table (in this case, it's the <code>Revision</code> table). Then run the following command against the FogBugz database:</p>
<p><code>CHECK TABLE Revision;</code></p>
<p>And if it comes back with an error:</p>
<p><code>REPAIR TABLE Revision;</code></p>
<p>If the table is large, the repair could take a while.</p>