Error Code: 1231. Variable 'slow_query_log_file'|mysql权限问题

ERROR 1231 (42000):Variable 'slow_query_log_file' can't be set to the value of '/var/log/slow.log'.

mysql> set global slow_query_log_file='/var/log/slow.log';
ERROR 1231 (42000): Variable 'slow_query_log_file' can't be set to the value of '/var/log/slow.log'

resolved

The problem was in permissions that wasn't correct on the destination folder.

check first:

mysql> show variables like '%dir%';

+-----------------------------------------+--------------------------------+

| Variable_name              | Value             |

+-----------------------------------------+--------------------------------+

...

| tmpdir                 | /tmp              |

+-----------------------------------------+--------------------------------+

17 rows in set (0.00 sec)

最快捷的方式选择一个有权限的目录。

set global slow_query_log_file='/tmp/slow.log';

mysql> set global slow_query_log=ON;

mysql> show variables like 'slow_query%';

+---------------------+---------------+

| Variable_name    | Value     |

+---------------------+---------------+

| slow_query_log   | ON      |

| slow_query_log_file | /tmp/slow.log |

+---------------------+---------------+

2 rows in set (0.00 sec)