Mysql – Environment Varibales in MySQL configuration file

configurationenvironment-variablesMySQL

It is possible to use environment variables in an Apache .conf file, but what about MySQL, is there a way to use them in the MySQL configuration file (my.ini/my.cfg)?

The closest thing I could find was a MySQL man-page that mentions some variables but does not indicate how to use them or if they are even system variables or internal variables.


In my case, I need a way to specify that the logs should be stored in a subdirectory of the system temp-directory, but cannot figure out how to indicate that. For example:

log-error="${temp}/MySQL_Logs/error.log"
innodb_log_group_home_dir="%temp%/PS_Logs/Logs/MySQL/"
?

Best Answer

You can't do it in the config file, but you can modify the start command to set them that way.

eg:

Set LOG_DIR="your log dir" in the console.

Then modify the start script to include the log-error option.

mysqld --log-error=$LOG_DIR/error_log.log
Related Topic