Use environment variables in my.ini/my.cnf

configuration, environment-variables, mysql

Solution

I think it is not possible. I tried making the same changes in MySQL option file, but failed to start. But there is another way though.

Set `MYSQL_DATA_HOME=<some dir>` in the console. And in the same terminal start mysql not by `service start` but with this command `mysqld --datadir=$MYSQL_DATA_HOME/whatever`

Problem

Is it possible to read env vars in MySQL option file my.ini/my.cnf, the way it is possible in httpd.conf and php.ini with the ${ENVVAR} syntax : ``` datadir="${MYSQL_DATA_HOME}/Data/" ``` If yes, what is the syntax ?

Original source