How To
Summary
Show the steps how to turn on MySQL (MariaDB) slow query log to detect queries that take too long to finish.
Objective
Turn on MySQL slow query log in order to find slow queries that take too long to finish.
Steps
1. To turn on slow query log when MySQL is running
Log in to MySQL as root, and run the following:
SET GLOBAL long_query_time = 1800; SET GLOBAL slow_query_log_file = '/var/lib/mysql/slow-query.log'; SET GLOBAL slow_query_log = 'ON';
In this case, any query longer than 1800 secs will be logged in /var/lib/mysql/slow-query.log
2. Make the changes permanent, even after MySQL restarts.
In /etc/my.cnf (or /etc/my.cnf.d/server.cnf for MariaDB), add
long_query_time = 1800 slow_query_log_file = /var/lib/mysql/slow_query.log
Document Location
Worldwide
[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSZT2D","label":"IBM Spectrum LSF RTM"},"Component":"","Platform":[{"code":"PF016","label":"Linux"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]
Was this topic helpful?
Document Information
More support for:
IBM Spectrum LSF RTM
Software version:
All Versions
Operating system(s):
Linux
Document number:
1171246
Modified date:
13 January 2020
UID
ibm11171246
Manage My Notification Subscriptions