该方法只适用于mysql5.6以上版本;
首先查询mysql是否开启慢查询功能
show variables like 'slow_query_log';
使用set global slow_query_log=1; 开启慢查询日记记录
使用show variables like 'slow_query_log_file';查看日记记录位置;
默认存储日志格式为file;
慢查询阈值,当查询时间多于设定的阈值时,记录日志
show variables like 'long_query_time';