Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I suppress the row count for tables added (AUTO_INCREMENT=N) to mysqldump output?

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?

like image 282
Marcus Avatar asked Feb 03 '09 14:02

Marcus


2 Answers

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
like image 186
Paolo Bergantino Avatar answered Sep 30 '22 17:09

Paolo Bergantino


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

?

like image 36
Pierre Avatar answered Sep 30 '22 17:09

Pierre