10

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:

SET GLOBAL VARIABLE foo=123;

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?

4 Answers 4

4

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

[mysqld]
max_connections=1000
foo=bar

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

1
  • what is the use of replacing mysql by mysqld ? Feb 13, 2021 at 7:57
3

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.

1

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

0

I edit the variable at /etc/mysql/mariadb.conf.d/50-server.cnf

under [server]

[server] 
innodb_file_format=barracuda
innodb_file_per_table=ON

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .