SET @num := 0; UPDATE your_table SET id = @num := (@num+1); /*set All previous values one by on*/
ALTER TABLE table_name AUTO_INCREMENT = start_value;