开发者

Slow query log in mysql

开发者 https://www.devze.com 2023-01-05 04:32 出处:网络
Can someone share how to enable slow query log (to see the slow queries) in Mysql 5 versions? I need to analyse the slow queries, please suggest.

Can someone share how to enable slow query log (to see the slow queries) in Mysql 5 versions?

I need to analyse the slow queries, please suggest.

Than开发者_Go百科ks in advance.


Begin by reading the documentation.

Edit

You can add one of the following lines in mysql server's configuration file:

log-slow-queries
log-slow-queries = /path/to/file

More recent versions of MySQL use these settings instead:

slow_query_log = 1
slow_query_log_file = /path/to/file

The slow query log file will contain the complete query text plus some additional information about the queries that take more then 10 seconds to execute. The 10 second threshold is configurable as well:

long_query_time = 10


If you want to enable general error logs and slow query error log

To start logging in table instead of file

mysql > set global log_output = “TABLE”;

To enable general and slow query log

mysql > set global general_log = 1;
mysql > set global slow_query_log = 1;

Table name in which logging is done by default

mysql > select * from mysql.slow_log;
mysql > select * from mysql.general_log;

For more details visit this link

http://easysolutionweb.com/technology/mysql-server-logs/

0

精彩评论

暂无评论...
验证码 换一张
取 消