snippetsqlMinor
How to set slow query log in MariaDB my.cnf?
Viewed 0 times
logquerycnfslowhowsetmariadb
Problem
It should be easy, but when I put these lines:
in
I looked at the docs, but could not figure out what is wrong in my configs.
Also , I've set the file permission to
However, I can set the parameters in command line:
and see that they are set:
```
+---------------------+--------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------------+--------------------------------------------------------------------------------------------------------------+
| log_slow_filter | admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk |
| log_slow_rate_limit | 1 |
| log_slow_verbosity | |
| slow_launch_time | 2 |
| slow_query_log | ON |
| slow_query_log_file | /var/log/mysql/slow_query.log |
+---------------------+-------------------------------------------
log_slow_queries = 1
long_query_time = 1
log-slow-queries = /var/log/mysql/slow_query.log
log_queries_not_using_indexesin
[mysqld], MariaDB fails to restart. I looked at the docs, but could not figure out what is wrong in my configs.
Also , I've set the file permission to
/var/log/mysql/slow_query.log# ls -al /var/log/mysql/slow_query.log
-rw-rw-r-- 1 mysql mysql 744682 Dec 4 23:46 /var/log/mysql/slow_query.logHowever, I can set the parameters in command line:
SET GLOBAL slow_query_log_file = '/var/log/mysql/slow_query.log';
SET GLOBAL LONG_QUERY_TIME = 1;
SET GLOBAL slow_query_log = 'ON';and see that they are set:
```
+---------------------+--------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------------+--------------------------------------------------------------------------------------------------------------+
| log_slow_filter | admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk |
| log_slow_rate_limit | 1 |
| log_slow_verbosity | |
| slow_launch_time | 2 |
| slow_query_log | ON |
| slow_query_log_file | /var/log/mysql/slow_query.log |
+---------------------+-------------------------------------------
Solution
You said you added this
That's the old way MySQL 5.0 sets the slow query log.
To activate the slow query log for MySQL 5.6 and MariaDB, you must use the following
Therefore, you need this in
log_slow_queries = 1
long_query_time = 1
log-slow-queries = /var/log/mysql/slow_query.log
log_queries_not_using_indexesThat's the old way MySQL 5.0 sets the slow query log.
To activate the slow query log for MySQL 5.6 and MariaDB, you must use the following
- slow_query_log
- slow_query_log_file
Therefore, you need this in
my.cnfslow_query_log = 1
long_query_time = 1
slow_query_log_file = /var/log/mysql/slow_query.log
log_queries_not_using_indexesCode Snippets
log_slow_queries = 1
long_query_time = 1
log-slow-queries = /var/log/mysql/slow_query.log
log_queries_not_using_indexesslow_query_log = 1
long_query_time = 1
slow_query_log_file = /var/log/mysql/slow_query.log
log_queries_not_using_indexesContext
StackExchange Database Administrators Q#122964, answer score: 9
Revisions (0)
No revisions yet.