Por: Gonzalo Escribano
reset auto_increment mysql
April 6, 2008
In certain versions of MySQL, truncate does NOT reset the auto_increment value to 0! Instead, it is mapped to DELETE. Make sure you consider this when designing your database, as the current manual does not seem to address this issue.
More information can be found here: http://bugs.mysql.com/11946
The above URL states that the bug is limited to unpatched versions 5.0.xx prior to version 5.0.3. However, I have noticed the same behavior in version 4.1.21.
That being said, here’s a very simple way to get around this problem without having to look for a patch and whatnot. After you use truncate to delete the contents of the table, you can use the alter table command to reset the auto increment manually. With that in mind, try this on the
table you want to clear:
alter table table_name auto_increment=1;