简体   繁体   中英

Slow query log in mysql

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.

Thanks 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

本文可能会帮助您了解如何在MySQL中记录慢速查询并使用mysqldumpslow实用工具对其进行分析,请查看http://www.installationpage.com/mysql/mysql-importance-slow-log-processing/

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM