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?
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
mysqldump --no-data --skip-add-drop-table | grep -v AUTO_INCREMENT
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With