The initscript for mysql (as of 5.0.54) assumes it can write to the /var/run/mysqld/ directory as the mysql user - this directory was created by the ebuild during installation. However, for users running /var/tmp on tmpfs (or any other ram-based filesystem) this directory is wiped out on reboots. The attached patch to the /etc/init.d/mysql initscript corrects this by including a check to see if the directory containing the pidfile exists. If it does not, the directory is created and chown-ed to the mysql user. This patch will be harmless for users who don't run /var/run on tmpfs as the directory will already exist. Reproducible: Always Steps to Reproduce: 1. emerge =dev-db/mysql-5.0.54 2. Set /var/run to be on tmpfs as in the following fstab line: tmpfs /var/run tmpfs mode=0755,size=10M 0 0 3. Reboot to initialize tmpfs mount (be sure /var/run is empty upon reboot - junk is often left here after reboots) 4. Attempt to start mysql. It fails to start and provides no useful information why since the initscript expected to create the PID file through start-stop-daemon. Actual Results: mysql fails to start. Expected Results: The initscript should create the /var/run/mysqld directory and chown it if necessary.
Created attachment 147775 [details, diff] Patch for mysql initscript with tmpfs This patch allows the mysql initscript to determine the mysql run directory (taken from the pidfile up to the final slash) and creates it if necessary with the proper user ownership. It will not affect users running /var/run on a standard persistent filesystem, so it should be safe for everyone.
(In reply to comment #0) For clarification: I meant "for users running /var/run on tmpfs", but above wrote "/var/tmp". I do mean /var/run in this case.
I found this patch very useful. Even for those not using tmpfs for their /var/run, it's not a bad idea to have this sanity check during the startup process.
This seems to be a user configuration issue to me. If we (Gentoo) want to address this issue, it probably should be addressed globally. To me this means providing a way for users to have /var/run on a tmpfs filesystem, which probably should create a tarball of everything under /var/run on shutdown and unpack it on startup. Thus, I'd suggest any user still interested on this issue to mail the gentoo-dev mailing list to determine if there's any interest or support for this feature. I don't think it makes any sense to fix this on a per-package basis.
Implemented in new mysql-init-scripts-2.0_pre1