Open MySQL Slow query
MySQL Slow query log for tracking Php+mysql system under the MySQL load tuning problem is very useful, such as installing a lot of discuz! plug-ins users, so you can probably troubleshoot those plug-ins have code problems. In fact, the slow query log to enable MySQL is very simple, only need to add log-slow-queries and long_query_time two parameters in the MySQL configuration file.
windows open MySQL slow query
The code is as follows |
Copy Code |
MySQL in Windows system configuration file is generally My.ini find [mysqld] below plus Log-slow-queries = F:/mysql/log/mysqlslowquery.log Long_query_time = 2 |
MySQL slow query enabled under Linux
MySQL in Windows system configuration file is generally my.cnf find [mysqld] below plus
The code is as follows |
Copy Code |
Log-slow-queries=/data/mysqldata/slowquery.log long_query_time=2 |
Attention
Log-slow-queries = F:/mysql/log/mysqlslowquery.log for slow query log storage location, general this directory to have MySQL running account can write permission, generally this directory is set to MySQL data storage directory;
2 of the long_query_time=2 means that the query is recorded for more than two seconds;
Updated September 24, 2009
Add the Log-queries-not-using-indexes parameter to the MY.CNF or My.ini, which indicates that the query that does not use the index is logged. Like what:
The code is as follows |
Copy Code |
Log-slow-queries=/data/mysqldata/slowquery.log long_query_time=2 Log-queries-not-using-indexes |
Today, I open MySQL slow query, MySQL service can not start, error:
[ERROR] Mysql:unknown variable ' log-slow-queries=d:/programdata/mysql/phpec_org-slow.log '
Half a day can not find the reason, after continuous Baidu, found that the original MYSQL5.6 version of the above has been canceled log-slow-queries This parameter, changed to Slow-query-log-file.