"Reprint Address: http://www.cnblogs.com/xzpp/archive/2012/07/18/2598136.html"
See if MySQL is enabled to view slow SQL log files
(1) To see if slow SQL logging is enabled
Mysql> Show variables like ' log_slow_queries ';
+------------------+-------+
| variable_name | Value |
+------------------+-------+
| log_slow_queries | On |
+------------------+-------+
1 row in Set (0.00 sec)
(2) View SQL that executes slower than how many seconds is logged to the log file
Mysql> Show variables like ' long_query_time ';
+-----------------+-------+
| variable_name | Value |
+-----------------+-------+
| Long_query_time | 1 |
+-----------------+-------+
1 row in Set (0.00 sec)
Value=1 here, for 1 seconds.
2. Configure the My.ini file (inux under File name my.cnf), find the [mysqld] section, increase the configuration of the log, as in the following example:
[Mysqld]
Log= "C:/temp/mysql.log"
Log_slow_queries= "C:/temp/mysql_slow.log"
Long_query_time=1
Log indicates the directory where logs are stored;
Log_slow_queries indicates the log directory of SQL logs with long execution time;
Long_query_time indicates how long the execution time is, Unit S.
These configuration items should already exist under Linux, just commented out, and you can remove the annotations. But adding configuration items directly is OK.
MySQL-View Slow SQL