Enabling MySQL slow query record log is useful for tracking MySQL load optimization problems in the PHP + MySQL system, such as installing a lot of Discuz! Plug-in users, so that you can probably find out which plug-ins have code problems. In fact, it is very easy to enable MySQL slow query logs. you only need to add the log-slow-queries and long_query_time parameters to the MySQL configuration file.
Today, a friend asked me to bring the record up. For more MySQL optimization information, see here: http://www.ccvita.com/category/mysql
Enable MySQL slow query in Windows
In Windows, the configuration file of MySQL is usually my. ini. find [mysqld] and add
Log-slow-queries = F:/MySQL/log/mysqlslowquery. log
Long_query_time = 2
Enable MySQL slow query in Linux
The configuration file of MySQL in Windows is usually my. cnf. find [mysqld] and add
Log-slow-queries =/data/mysqldata/slowquery. log
Long_query_time = 2
Note:
Log-slow-queries = F:/MySQL/log/mysqlslowquery. log is the location where full query logs are stored. Generally, this directory requires the write permission of the MySQL running account. Generally, this directory is set to the MySQL data storage directory;
2 in long_query_time = 2 indicates that the query takes more than two seconds to record