0

I am having a issue regarding permissions in MariaDB (MySQL) log files. I had setup logs files to be on /var/log/mysql but any time I restart the MariaDB server I can see the following messages logged in /var/log/mysql/mysql_error.log:

151104 20:54:53 [ERROR] mysqld: File '/var/log/mysql/mysql_slow.log' not found (Errcode: 13)
151104 20:54:53 [ERROR] Could not use /var/log/mysql/mysql_slow.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
151104 20:54:53 [ERROR] mysqld: File '/var/log/mysql/mysql_query.log' not found (Errcode: 13)
151104 20:54:53 [ERROR] Could not use /var/log/mysql/mysql_query.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.

I have tried setting up permissions on /var/log/mysql recursive (-R) as mysql:root, mysql:mysql and root:root none of them works and I got the same messages all the time. I did check the current permissions on /var/log/mysql and read as:

# ls -l mysql/
total 40
-rw-r--r-- 1 mysql root 33088 Nov  4 21:04 mysql_error.log
-rw-r--r-- 1 mysql root     0 Aug  2 16:58 mysql_query.log
-rw-r--r-- 1 mysql root     0 Aug  2 16:58 mysql_slow.log

I am using mysql Ver 15.1 Distrib 5.5.46-MariaDB, for Linux (x86_64) using readline 5.1

What is wrong here? Which are the right permissions on this case?

Update

Here are the permissions for /var/log and /var/log/mysql:

# ls -lhd /var/log/
drwx------ 12 root root 4.0K Nov  4 20:52 /var/log/
# ls -lhd /var/log/mysql
drwxr-xr-x 2 mysql root 4.0K Nov  4 20:52 /var/log/mysql
  • 1
    Few things to check (A) /var/log/ & /var/log/mysql/ must have read&execute permissions for all users (B) when mysql is running, there will be two processes, 1 running as root and 1 running as some other user (most common user is "mysql") so get the ps output and find which user is running the mysql process. – Prem Nov 5 '15 at 3:48
  • @Prem I have updated the answer - take a look - though I am not following you on your statement here must have read&execute permissions for all users can you explain that? Is secure to change those permissions or it can affect any other process logging? And I look the user with ps -ax and it's mysql so it's right – ReynierPM Nov 5 '15 at 18:56
  • 2
    From your update, service is running as correct mysql user , so (B) is resolved. I see that (A) is the problem : Currently, mysql user can not look into /var/log/ so "chmod 755 /var/log/" will solve your problem. Default for /var/log/ is rwxr-xr-x & it is only for writing log files, so it is not a security risk. – Prem Nov 5 '15 at 19:58
1

I believe you have to give the mysql user read and execute permissions to /var/log before it can access /var/log/mysql. I just tested this on RHEL7.1 and confirmed the same issue.

This is precisely as @prem suggested in the comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.