From 07dd71da971d35a208895826873f2a3b6f617445 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 22 May 2020 01:12:59 +0200 Subject: [PATCH] Add file 'README.missing-socket-directory'. --- README.missing-socket-directory | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 README.missing-socket-directory diff --git a/README.missing-socket-directory b/README.missing-socket-directory new file mode 100644 index 0000000..d2315bd --- /dev/null +++ b/README.missing-socket-directory @@ -0,0 +1,51 @@ +## +# +# MySQL and MariaDB socket-file/pid-file folder issues – how to fix +# +## + +# ---------- +# There are 2 possibilities to force creating a folder on ech boot. +# ---------- + + +# ---------- +# +# 1.) Add 'ExecStartPre' directive to systemd service file: +# +# ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld +# +# ---------- + +MYSQL_USER=mysql +SOCKET_DIR="/var/run/mysqld" +MYSQL_SERVICE_FILE="/root/mysql.service" + +perl -i -n -p -e "s&^(PermissionsStartOnly=.*)&\1\n\nExecStartPre=/usr/bin/install -m 755 -o $MYSQL_USER -g root -d $SOCKET_DIR&" $MYSQL_SERVICE_FILE + + +# ---------- +# +# 2.) Create file /etc/tmpfiles.d/mysql.conf file with content: +# +# # systemd tmpfile settings for mysql or mariadb +# d /var/run/mysqld 0755 mysql mysql - +# +# see also: +# https://www.ryadel.com/en/linux-mysql-mariadb-pid-file-folder-fix/ +# +# ---------- + +# Force systemd to create such folder on each startup. We can easily do that following the steps below: +# +# - Create a new /etc/tmpfiles.d/mysql.conf file with content: +# +# # systemd tmpfile settings for mysql or mariadb +# d /var/run/mysqld 0755 mysql mysql - +# +cat < /etc/tmpfiles.d/mysql.conf +# systemd tmpfile settings for mysql or mariadb +d /var/run/mysqld 0755 mysql mysql - +EOF + +