Re:An open MySQL bug receives a real Birthday cake
by AaronBBrown on Friday June 28, 2013 @03:51PM
(#5960009)
While I agree it has potential to be annoying in some environments, it's also trivially simple to work around.
for tbl in $(mysql -BNe "SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE EXTRA = 'auto_increment' AND TABLE_SCHEMA = 'mydb'"); do
mysql -e "ALTER TABLE ${tbl} AUTO_INCREMENT=1" mydb
done
Run that just after importing your new schema.
Note: That code will require a bit of modification if you make the mistake of having spaces in your table name.
Note: That code will require a bit of modification if you make the mistake of having spaces in your table name.