'Mysql slow query log Errcode: 13 - Permission denied

I want to enable slow query log. When I execute the following query

set global slow_query_log = 'ON';

I get :

#29 - File '/var/log/mysqld_slow.log' not found (Errcode: 13 - Permission denied)

I tried solution here : https://bugs.mysql.com/bug.php?id=98340 but I have issue on last command :

touch /var/log/mysqld_slow.log
chown mysql:mysql /var/log/mysqld_slow.log (also tried mysql:adm)
chmod 640 /var/log/mysqld_slow.log (also tried 666)
chcon -t mysqld_log_t /var/log/mysqld_slow.log
chcon: can't apply partial context to unlabeled file '/var/log/mysqld_slow.log'


Solution 1:[1]

I'm not sure to understand why, but changing the path to /var/log/mysql/mysqld_slow.log is working.

Certainly due to parent folder permissions ?

Can't have a solution to put file in /var/log/mysqld_slow.log ? I'm using ubuntu

Solution 2:[2]

Just rename the file in MySQL variables to some new name, I have just renamed the file from a variable and it is working properly. And MySQL automatically created the file for me in the path. The defautl path is: /var/log/mysql/slow_query.log - rename the file to slow_query_log or something else

Hope it may work for you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fred
Solution 2 Atmiya Kolsawala