Mysql – Passing Arguments to a Service started with Init.d

init.dMySQL

I want to start mysql with the command argument "–log=log_file_name"

What is the proper way to do that when starting it with /etc/init.d?

Would it be like this?
/etc/init.d/mysql start –log=log_file_name

Best Answer

To make it simple you can create another entry in init.d to start the mysql with that logdir path option. Make a script like /etc/init.d/mysql-log and put following entries in it:

 #!/bin/sh -e
 set -e
 COMMAND=$1
 LOG="--log=/tmp/mysql.log"
 case $COMMAND in
 start)
      /etc/init.d/mysql $COMMAND $LOG
      ;;
 stop)
      /etc/init.d/mysql $COMMAND
      ;;
 restart)
      /etc/init.d/mysql stop
      /etc/init.d/mysql start $LOG
      ;;
 *)
      exit 1
 esac

Set the log file location in the above script as per your needs and start the mysql with the following command:

/etc/init.d/mysql-log start 

This way you can use different scripts for different occasions.

Related Topic