views:

475

answers:

2

I use the following command to output the schema for a MySQL db:

mysqldump --no-data --skip-add-drop-table

I will do this for two databases I want to compare, and then diff the two output files. This is my crude way of tracking database changes between environments.

However, a minor inconvenience to me is that the row count for each table is included as part of the table definition, as the AUTO_INCREMENT value, like so:

ENGINE=MyISAM AUTO_INCREMENT=844 DEFAULT CHARSET=latin1;

I would think that the '--no-data' flag would suppress any information about the table that references the data, including number of rows.

How do I suppress AUTO_INCREMENT=N in this output?

+1  A: 

mysqldump --no-data --skip-add-drop-table | grep -v AUTO_INCREMENT

?

Pierre
Well, AUTO_INCREMENT is on the same line as ENGINE and CHARSET, any differences in which I *would* want to see... so, I don't want to omit the entire line. Thank you though!
Marcus
+4  A: 

Check out this ticket on this problem. It was closed as "Won't Fix"

You could do this, alternatively:

mysqldump --no-data --skip-add-drop-table my_database | sed 's/AUTO_INCREMENT=[0-9]*\b//' > database.dump
Paolo Bergantino
Thanks, I wish there was some way to mark this "great answer" because it truly is, considering the reference to the actual bug report etc. Bravo and thank you!
Marcus