mysql的慢查询日志使用步骤

  1. 开启慢查询
  2. 设置sql慢查询的时间
  3. 确定慢查询的日志路径:在Data路径下
  4. 确定慢查询的日志文件名
mysql> show processlist
    -> ;
+----+------+-----------------+--------+---------+-------+----------+------------------+
| Id | User | Host            | db     | Command | Time  | State    | Info             |
+----+------+-----------------+--------+---------+-------+----------+------------------+
|  2 | root | localhost:6073 | m| Sleep   | 14152 |          | NULL             |
|  3 | root | localhost:6018 | m | Sleep   | 14183 |          | NULL             |
|  4 | root | localhost:6184 | NULL   | Query   |     0 | starting | show processlist |
+----+------+-----------------+--------+---------+-------+----------+------------------+
3 rows in set (0.00 sec)



mysql> set global slow_query_log = on
    -> ;
Query OK, 0 rows affected (0.00 sec)



mysql> set global long_query_time = 0.01;
Query OK, 0 rows affected (0.00 sec)


mysql> show global variables like "datadir";
+---------------+-----------------------------------------------------------------+
| Variable_name | Value                                                           |
+---------------+-----------------------------------------------------------------+
| datadir       | D:\software\Mysql\mysql-5.7.38-winx64\mysql-5.7.38-winx64\data\ |
+---------------+-----------------------------------------------------------------+
1 row in set, 1 warning (0.01 sec)



mysql> show global variables like "slow_query_log_file";
+---------------------+-----------------------------------------------------------------------------------+
| Variable_name       | Value                                                                             |
+---------------------+-----------------------------------------------------------------------------------+
| slow_query_log_file | D:\software\Mysql\mysql-5.7.38-winx64\mysql-5.7.38-winx64\mysqllog\slow_query.log |
+---------------------+-----------------------------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql>

一篇慢查询的博客:https://www.51cto.com/article/618217.html

你可能感兴趣的:(go打卡学习集合,mysql,android,数据库)