MYSQL5.7以上才支持
Enable: UPDATE performance_schema.setup_instruments SET ENABLED = 'YES', TIMED = 'YES' WHERE NAME = 'wait/lock/metadata/sql/mdl'; Disable: UPDATE performance_schema.setup_instruments SET ENABLED = 'NO', TIMED = 'NO' WHERE NAME = 'wait/lock/metadata/sql/mdl';
每个线程持有的MDL锁在metadata_locks表有详情:
SELECT * FROM performance_schema.metadata_locks
参考文档:https://dev.mysql.com/doc/refman/5.7/en/performance-schema-metadata-locks-table.html