Skip to content

Instantly share code, notes, and snippets.

@abhinavlal
Created January 19, 2013 08:45
Show Gist options
  • Save abhinavlal/4571478 to your computer and use it in GitHub Desktop.
Save abhinavlal/4571478 to your computer and use it in GitHub Desktop.
Reset auto increment of all tables in a mysql database
mysql -Nsr -e "SELECT t.table_name FROM INFORMATION_SCHEMA.TABLES t WHERE t.table_schema = 'DB_NAME'" | xargs -I {} mysql DB_NAME -e "ALTER TABLE {} AUTO_INCREMENT = 1;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment