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() {
# 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"
}
[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