mysql性能优化

mysql的慢查询开启方式和存储格式

1,查看慢查询是否开启

show variables like 'slow_query_log';

2,在确认是否开启慢查询日志之间需要去查看是否将没有使用索引的sql记录在慢查询日志中

show variables like '%log%';   -->log_queries_not_using_indexs

3,将未使用索引的 sql记录在慢查询日志中

set global log_queries_not_using_indexs=on;

4,查询时间 控制限制

show variables like 'long_query_time';

5,将慢查询日志记录设置为On;

set global slow_query_log=on;

6,查看慢查询日志所记录的位置

show variables like 'show%';

7,使用explain查询sql的执行记录       

待续。。

原文地址:https://www.cnblogs.com/myadmin/p/4910286.html