1

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'
Fred
  • 399
  • 3
  • 12
  • Sounds like apparmor is blocking you. If you try to make a service create a file in an unauthorized location, the security service will block that. Read https://www.percona.com/doc/percona-server/8.0/security/apparmor.html and see if that helps. – Bill Karwin Oct 19 '21 at 15:28

3 Answers3

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

Fred
  • 399
  • 3
  • 12
1

in my case, i just remove the file

rm -rf mysqld_slow.log

and then restart mysql

systemctl restart mysql

it regenerate the file, it works

0

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.

Atmiya Kolsawala
  • 475
  • 4
  • 12