Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add an extra configuration file for mysql (my.cnf)

Tags:

unix

mysql

I want to add and extra configuration file for MySQL on UNIX, let's call it my2.cnf. So when MySQL starts, it would read the options of that file too.

Here it says that I can put a file on the following places:

  • /etc/my.cnf
  • SYSCONFDIR/my.cnf
  • $MYSQL_HOME/my.cnf
  • defaults-extra-file The file specified with --defaults-extra-file=path, if any
  • ~/.my.cnf User-specific options

I would like something like this "default-extra-file", but avoiding to enter this command on the mysql prompt.

Is there an option in the cnf file like:

 extra-conf-file=/path/to/my/file/my2.cnf

(Unfortunately that does not work)

Is that even possible? Can I use the default my.cnf file to add another configuration file that will be read when I start themysql service?

(Using $MYSQL_HOME/my.cnf is good enough for me, but I would like to know if I can explicetely tell so it can be read or ignored according to the main my.cnf global file).

like image 754
Cesc Avatar asked Mar 29 '13 01:03

Cesc


1 Answers

I guess this is what you want right ?

!include /path/to/my/file/my2.cnf

You can also include a complete set of files from a directory using:

!includedir /path/to/my.cnf.d
like image 75
joamag Avatar answered Nov 01 '22 23:11

joamag