How do I change the Auto Increment counter in MySQL?

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


There may be a quicker way, but this is how I would do it to be sure I am recreating the IDs;

If you are using MySQL or some other SQL server, you will need to:

  1. Backup your database
  2. Drop the id column
  3. Export the data
  4. TRUNCATE or 'Empty' the table
  5. Recreate the id column as auto_increment
  6. Reimport the data

This will destroy the IDs of the existing rows, so if these are important, it is not a viable option.


The auto increment counter for a table can be (re)set two ways:

  1. By executing a query, like others already explained:

    ALTER TABLE <table_name> AUTO_INCREMENT=<table_id>;

  2. Using Workbench or other visual database design tool. I am gonna show in Workbench how it is done - but it shouldn't be much different in other tool as well. By right click over the desired table and choosing Alter table from the context menu. On the bottom you can see all the available options for altering a table. Choose Options and you will get this form: enter image description here

    Then just set the desired value in the field Auto increment as shown in the image. This will basically execute the query shown in the first option.