I'm writing an application that attempts to configure several MySQL servers remotely. Part of this configuration involves setting global MySQL variables using SQL syntax like this:


This works well, but it only lasts until the server is restarted. What I would like is a way to make MySQL write these changes to an options (.ini) file, such that they are persistent across machine reboots.

I'm trying to edit the options files without actually opening them directly - I'd prefer to do everything through the MySQL connection.

Does anyone know if this can be done?


set-variable=var_name=value is the classic method to do this in my.cnf. Also, you can specify using flags as --set-variable=var_name=value. Earlier than MySQL 4.0.2, most configuration options were set using this method.

This is depreciated and even removed in MySQL 5.5. Most options can be set using their actual names in the my.cnf. If you need further help, please be more specific.


To make a global system variable setting permanent, you should set it in an option file: http://dev.mysql.com/doc/refman/5.0/en/option-files.html


You just can add all the variables to /etc/mysql/conf.d/mysql.cnf file just after [mysqld].


if you found [mysql] replace it with [mysqld]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.