Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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