Enable the slow query log at runtime
find slow mysql queries | enable slow query log | database slowing down website | mysql | mariadb | slow-log | performanceCaution: This command changes the system. Understand what it does before you run it.
mysql -e 'SET GLOBAL slow_query_log = 1; SET GLOBAL long_query_time = 2; SHOW VARIABLES LIKE "slow_query_log_file";'Enables the slow query log and sets the threshold above which queries are logged. The path of the log file is printed afterwards. The setting lasts until the next restart of the database service, and new connections pick up the threshold.
Note: Turn it off with SET GLOBAL slow_query_log = 0;. To make it permanent, add it to /etc/mysql/mariadb.conf.d/50-server.cnf. With a low threshold, the log grows quickly.
Also searched as
- find slow mysql queries
- enable slow query log
- database slowing down website