Have you tried MySQLTuner yet? It's free and it makes optimizing your MySQL server easier than ever!

Table corruption in MySQL can often wreak havoc on the auto_increment fields. I’m still unsure why it happens, but if you find a table tries to count from 0 after a table corruption, just find the highest key in the column and add 1 to it (in this example, I’ll say the highest key is 9500).

Just run this one SQL statement on the table:

ALTER TABLE brokentablename AUTO_INCREMENT=9501;

If you run a quick insert and then run SELECT last_insert_id(), the correct key number should be returned (9501 in this case).

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis
Leave a Reply

You must be logged in to post a comment. Login »