package/mariadb: explicitly define logging directory to mysqld

By default, mariadb creates logging files under the data directory.
This patch updates the startup scripts to log under /var/log/mysql.

Signed-off-by: Ryan Coe <bluemrp9@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
Ryan Coe 2020-02-03 17:21:58 -08:00 committed by Peter Korsgaard
parent 3bbf01869f
commit 2b653736ce
2 changed files with 8 additions and 2 deletions

View file

@ -6,6 +6,8 @@
MYSQL_LIB="/var/lib/mysql"
MYSQL_RUN="/run/mysql"
MYSQL_PIDFILE="$MYSQL_RUN/mysqld.pid"
MYSQL_LOG="/var/log/mysql"
MYSQL_LOGFILE="$MYSQL_LOG/mysqld.log"
MYSQL_BIN="/usr/bin"
wait_for_ready() {
@ -38,11 +40,14 @@ start() {
# so create a subdirectory for mysql.
install -d -o mysql -g root -m 0755 $MYSQL_RUN
# Also create logging directory as user mysql.
install -d -o mysql -g root -m 0755 $MYSQL_LOG
# We don't use start-stop-daemon because mysqld has its own
# wrapper script.
printf "Starting mysql ... "
$MYSQL_BIN/mysqld_safe --pid-file=$MYSQL_PIDFILE --user=mysql \
> /dev/null 2>&1 &
--log-error=$MYSQL_LOGFILE > /dev/null 2>&1 &
wait_for_ready
[ $? = 0 ] && echo "OK" || echo "FAIL"
}

View file

@ -3,7 +3,8 @@ Description=MySQL database server
[Service]
ExecStartPre=/bin/sh -c 'test "`ls -1 /var/lib/mysql | wc -l`" != "0" || mysql_install_db --basedir=/usr --datadir=/var/lib/mysql && chown -R mysql:mysql /var/lib/mysql'
ExecStart=/usr/bin/mysqld_safe
ExecStartPre=install -d -o mysql -g root -m 0755 /var/log/mysql
ExecStart=/usr/bin/mysqld_safe --log-error=/var/log/mysql/mysqld.log
Restart=always
User=mysql
RuntimeDirectory=mysql