1, the slow log status;
Mysql> Show variables like '%slow% ';
+---------------------+------------------------------------------+
| variable_name | Value |
+---------------------+------------------------------------------+
| log_slow_queries | On |
| Slow_launch_time | 2 |
| Slow_query_log | On |
| Slow_query_log_file | /mysqllog/slow_log/slow_queries_3306.log |
+---------------------+------------------------------------------+
4 rows in Set (0.00 sec)
2, stop the slow log server.
mysql> set global slow_query_log=0;
Query OK, 0 rows affected (0.27 sec)
Mysql> Show variables like '%slow% ';
+---------------------+------------------------------------------+
| variable_name | Value |
+---------------------+------------------------------------------+
| log_slow_queries | Off |
| Slow_launch_time | 2 |
| Slow_query_log | Off |
| Slow_query_log_file | /mysqllog/slow_log/slow_queries_3306.log |
+---------------------+------------------------------------------+
4 rows in Set (0.00 sec)
Mysql>
Mysql> Show variables like '%slow% '; --Check slow log status
+---------------------+------------------------------------------+
| variable_name | Value |
+---------------------+------------------------------------------+
| log_slow_queries | Off |
| Slow_launch_time | 2 |
| Slow_query_log | Off |
| Slow_query_log_file | /mysqllog/slow_log/slow_queries_3306.log |
+---------------------+------------------------------------------+
4 rows in Set (0.00 sec)
3, reset the new path of slow log
mysql> set global slow_query_log_file= '/mysqllog/slow_log/slow_queries_3306_new.log ';
Query OK, 0 rows affected (0.03 sec)
4, start the slow log server
Mysql>
Mysql>
mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.01 sec)
Mysql> Show variables like '%slow% ';
+---------------------+----------------------------------------------+
| variable_name | Value |
+---------------------+----------------------------------------------+
| log_slow_queries | On |
| Slow_launch_time | 2 |
| Slow_query_log | On |
| Slow_query_log_file | /mysqllog/slow_log/slow_queries_3306_new.log |
+---------------------+----------------------------------------------+
4 rows in Set (0.00 sec)
5, check the slow SQL in the new slow log file.
Mysql> Select Sleep (a) as a, 1 as B;
+---+---+
| A | B |
+---+---+
| 0 | 1 |
+---+---+
1 row in Set (10.00 sec)
Mysql>
[Mysql@xxx-xxx ~]$ More/mysqllog/slow_log/slow_queries_3306_new.log
......
Time Id Command Argument
# time:140213 6:44:24
# User@host:root[root] @ localhost []
# query_time:10.000365 lock_time:0.000000 rows_sent:1 rows_examined:0
SET timestamp=1392273864;
Select Sleep as a, 1 as B;
6, backup the old big slow log file to other directory.
mv/mysqllog/slow_log/slow_queries_3306.log/mysqlbackup/slow_log/slow_queries_3306.log.bak.20140213