How do I change the Auto Increment counter in MySQL?

Chris Olson picture Chris Olson · Nov 17, 2011 · Viewed 38.3k times · Source

I have an ID field that is my primary key and is just an int field.

I have less than 300 rows but now every time someone signs up that ID auto inc is inputted really high like 11800089, 11800090, etc.... Is there a way to get that to come back down so it can follow the order (310,311,312).

Thanks!

Answer

Brad picture Brad · Nov 17, 2011
ALTER TABLE table_name AUTO_INCREMENT=310;

Beware though, you don't want to repeat an ID. If the numbers are that high, they got that way somehow. Be very sure you don't have associated data with the lower ID numbers.

https://dev.mysql.com/doc/refman/8.0/en/example-auto-increment.html