Could not use /var/log/mysqld-slow.log for logging (error 13 - Permission denied).

Description

configuration file /etc/my.cnf:

log_error = /var/log/mysqld.log

slow_query_log_file = /var/log/mysqld-slow.log

if I delete both of these files and restart mysqld service - behavior is different:

log file /var/log/mysqld.log is created with permissions 0640 and ownetr:group mysql:mysql.

log file /var/log/mysqld-slow.log not created and MySQL write warning message to log file /var/log/mysqld.log:

Could not use /var/log/mysqld-slow.log for logging (error 13 - Permission denied). Turning logging off for the server process. To turn it on again: fix the cause, then either restart the query logging by using "SET GLOBAL SLOW_QUERY_LOG=ON" or restart the MySQL server.

=====================

If MySQL server can create /var/log/mysqld.log log file on the startup, when this file is absent, but don`t want to create log file /var/log/mysqld-slow.log ?

Looks like this is bug/inconsistency in the MySQL.

Can you please fix this bug and automatically create both of these files on mysqld startup?

Workaround for this bug:

$ cat /etc/systemd/system/mysqld.service.d/override.conf

[Service]
LimitNOFILE = 8388608

ExecStartPre=+touch /var/log/mysqld-slow.log
ExecStartPre=+chown mysql:mysql /var/log/mysqld-slow.log
ExecStartPre=+chmod 0600 /var/log/mysqld-slow.log

ExecStartPre=+touch /var/log/mysqld.log
ExecStartPre=+chown mysql:mysql /var/log/mysqld.log
ExecStartPre=+chmod 0600 /var/log/mysqld.log

ExecStartPre=+/usr/bin/mysqld_pre_systemd

Environment

percona-server-server-8.0.32-24.1.el9.x86_64.rpm from official percona server repo

Attachments

1

Activity

Show:

Gena Makhomed May 8, 2023 at 9:20 PM

MySQL can create error log at startup, but can't create slow log at startup - you think this is not bug? Hm, this is strange.

Provided  https://bugs.mysql.com/bug.php?id=98340 is useless, because I do not use SELinux at all, selinux is disabled by kernel command line:

  1. cat /proc/cmdline
    ... selinux=0

Root cause of bug:

MySQL tries to create slow log file after dropping process owner from root to mysql, but MySQL create error log file before dropping process owner from root to mysql.

This is root cause of this stupid error message:

Could not use /var/log/mysqld-slow.log for logging (error 13 - Permission denied).

How to fix this bug:

create slow log file together with error log file, before dropping process owner from root to mysql.

 

Aaditya Dubey April 24, 2023 at 7:33 AM

Hi ,

Thank you for the report.
This is not a bug, please go through https://bugs.mysql.com/bug.php?id=98340 and proceed as described.

Not a Bug

Details

Assignee

Reporter

Needs QA

Yes

Affects versions

Priority

Smart Checklist

Created April 24, 2023 at 3:28 AM
Updated March 6, 2024 at 9:43 AM
Resolved April 24, 2023 at 7:34 AM
Loading...