Log DDL changes

from the Artful MySQL Tips List


MySQL logs DDL statements to a DDL log but it's not human-readable and the server daemon deletes it on every restart.

That implies two longshot possibilities for DDL logging ...

(i) modify server source to add a persisting human-readable form of the DDL of the log,

(ii) make a feature request for that at https://bugs.mysql.com/ ... and two more plausible alternatives ...

(iii) fetch DDL statements from the general log (https://dev.mysql.com/doc/refman/8.0/en/query-log.html)

(iv) fetch DDL statements from the binary log. From https://dba.stackexchange.com/questions/91185/how-to-track-only-ddl-statements-executed-in-mysql: If you are using MySQL 5.6 (or later) and should you decide to bite the bullet and use mysqlbinlog and parse the output, you may need to setup mysqlbinlog on an external server, redirecting output to your own log file for DDLs. You will also have to use stop-never. here is what the MySQL Documentation says on stop-never:

This option is used with --read-from-remote-server. It tells mysqlbinlog to remain connected to the server. Otherwise mysqlbinlog exits when the last log file has been transferred from the server. stop-never implies --to-last-log, so only the first log file to transfer need be named on the command line. --stop-never is commonly used with --raw to make a live binary log backup, but also can be used without --raw to maintain a continuous text display of log events as the server generates them.

Last updated 18 Apr 2020


Return to the Artful MySQL Tips page