Bug #100506 mysqld.service does not create /var/run/mysqld after reboot
Submitted: 12 Aug 2020 14:54 Modified: 13 Aug 2020 20:02
Reporter: Will Haines Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.7.31 OS:Red Hat
Assigned to: CPU Architecture:Any

[12 Aug 2020 14:54] Will Haines
Description:
In order to start mysqld.service tries to create a pid file at /var/run/mysqld/mysqld.pid.

When installed, the mysql-community-server-5.7.31-1.el7.x86_64 rpm creates the /var/run/mysqld directory, however this directory is wiped upon reboot.

It appears the same issue was previously fixed in Bug #89997, but that fix was lost during the transition to systemd.

How to repeat:
1. Install mysql-community-server-5.7.31-1.el7.x86_64 on a rhel7 server
2. Reboot
3. See that mysqld fails to start.
4. In /var/log/mysqld.log:

[ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)

Suggested fix:
A section should be added to 

ExecStartPre=/usr/bin/mysqld_pre_systemd

that mimics the patch presented in Bug #89997
[13 Aug 2020 7:39] Terje Røsten
Hi!

Thanks for your report!

During reboot on systemd enabled systems (most modern Linux distros)
/var/run is removed, to re-create files and dirs, tmpfiles.d is used:

 https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html

Hence, MySQL server package ships file:

 /usr/lib/tmpfiles.d/mysql.conf 

with content:

 d /run/mysqld 0755 mysql mysql  -

Is this file not present in your systems or is tmpfiles service not
enabled?
[13 Aug 2020 18:18] Will Haines
Hi Terje,

Thanks for the info on how that directory is supposed to be created. I wasn't aware of tmpfiles.service.

It seems our problem was due to the mysql user being defined in our AD, and tmpfiles.service running before sssd came up.

Ultimately, it is an issue unique to our environment, not a true bug in mysql. This report may be closed now.

Will
[13 Aug 2020 20:02] Will Haines
This turned out to be unique to our infrastructure, not an upstream bug.