每次用完就忘~
- 查看慢sql 相关配置:show variables like ‘slow%’;
- 慢sql 时间设置:set long_query_time=1; # 超过1毫秒就是慢sql
- 打开 optimizer_trace,只对本线程有效:set optimizer_trace=‘enabled=on’;
- 查看 optimizer_trace 输出:select * from information_schema.OPTIMIZER_TRACE\G
- 修改表名:alert table old_name rename as new_name;
- 查询 MDL 锁:select blocking_pid from sys.schema_table_lock_waits;
先设置 UPDATE performance_schema.setup_instruments SET ENABLED = 'YES', TIMED = 'YES' where name='wait/lock/metadata/sql/mdl'
; - 查询行锁:select * from sys.innodb_lock_waits\G
- 查看binlog配置:show variables like ‘%log_bin%’;
开启binlog:[mysqld] 追加 log-bin=mysql-bin server-id=1
- 查看binlog文件列表:show binary logs;
- 查看正在写的binlog文件:show binlog events;
- 查看指定binlog文件:show binlog events in ‘mysql-bin.000001’;
本文地址:https://blog.csdn.net/qq_27007509/article/details/110953196