Fred
Fred

Reputation: 419

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'

Upvotes: 3

Views: 5878

Answers (4)

Salo SMarmeladom
Salo SMarmeladom

Reputation: 1

If chown and chmod don't help, there is a possibility that some security app blocks access to your file. If so, you will see some messages in /var/log/messages like "SELinux is preventing /usr/sbin/mysqld from write access on the directory [your directory]".

In case of apparmor you can follow this answer https://stackoverflow.com/a/56850952/27734465

In case of SElinux try semanage permissive -a mysqld_t

Upvotes: 0

Abdul Rahman Effendi
Abdul Rahman Effendi

Reputation: 11

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

Upvotes: 1

Atmiya Kolsawala
Atmiya Kolsawala

Reputation: 485

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.

Upvotes: 1

Fred
Fred

Reputation: 419

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

Upvotes: 1

Related Questions