You are currently viewing How to reset AUTO_INCREMENT in MySQL and start counting from 1 again?

How to reset AUTO_INCREMENT in MySQL and start counting from 1 again?

  • Post category:MySQL
  • Post comments:0 Comments

Let say you have a table called “my_table” with an auto-increment column called “id” and you want the id column to start counting from 1,2,3,… then use the following SQL queries.

SET  @num := 0;

UPDATE my_table SET id = @num := (@num+1);

ALTER TABLE my_table AUTO_INCREMENT =1;