MySQLdump Exclude master-data

MySQLmysql-5.6mysqldumpreplication

Is it possible to exclude the master data from a mysql dump? From the manual it seems like the only options are commented out or present. I don't need the data at all because it is going to a static system. Commented out will work but just wondering if 0 or some other value would make it not present?

Use this option to dump a master replication server to produce a dump file that can be used to set up another server as a slave of the master. It causes the dump output to include a CHANGE MASTER TO statement that indicates the binary log coordinates (file name and position) of the dumped server. These are the master server coordinates from which the slave should start replicating after you load the dump file into the slave.

If the option value is 2, the CHANGE MASTER TO statement is written as an SQL comment, and thus is informative only; it has no effect when the dump file is reloaded. If the option value is 1, the statement is not written as a comment and takes effect when the dump file is reloaded. If no option value is specified, the default value is 1.

https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_master-data

My plan was to use:

mysqldump --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=0 ...

but from the above entry that would put the CHANGE MASTER TO as an uncommented command.

Best Answer

Use grep -v with --master-data=2

mysqldump --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 | grep -v "^-- CHANGE MASTER TO" > dump.sql

GIVE IT A TRY !!!