search
top

Resetting MySQL Auto Increment Field

After developing a number of systems in the past it is of course essential to completely test any piece of software. This of course means that any tables that use an auto_increment field will not start from 1 when the system goes live. Not a massive problem but it is nice sometimes to reset the value to 1.

After searching around the web what seemed like an age I finally found the SQL that carry s out just the job.

Enter the following statement into your MySQL database replacing tablename with the name of your table and the value x to the number you want the AUTO_INCREMENT value to start from:

ALTER TABLE tablename AUTO_INCREMENT = x

There you go the AUTO_INCREMENT field in this case will now be reset to 1

Related posts:

  1. Getting The Last Auto Increment Field With PHP
  2. Connecting to MySQL with PHP
  3. Database Connections Outside of Webroot
  4. Reseting DNS cache in Windows, Mac OS X and Linux

Leave a Reply

top