11

As per title. In /etc/mysql/my.cnf I see:

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

.cnf files from both location are loaded: why having two? Which one is the "right one" for my own .cnf?

3 Answers3

8

In my case I had to add all my changes to the directory /etc/mysql/mysql.conf.d/ because it gets loaded last. So I added a file zz_myconfig.cnf to that directory with all my changes. The other way around the configuraion from /etc/mysql/mysql.conf.d/mysqld.cnf would overwrite my settings again which is unfortunate.

If the directory /etc/mysql/conf.d is the official way to go then it should also be the last include directory within /etc/mysql/my.cnf.

3

Both are global options. In this case,

!includedir /etc/mysql/mysql.conf.d/

is an SYSCONFDIR generate by ubuntu when Mysql was compiling for the package in CMAKE option.

More info https://dev.mysql.com/doc/refman/8.0/en/option-files.html

Pserr
  • 42
  • 3
  • 5
    Thanks for your reply. So I understand that `/etc/mysql/mysql.conf.d` is there just for retrocompatibility and `/etc/mysql/conf.d` is the way to go, right? – Dr. Gianluigi Zane Zanettini Feb 16 '19 at 23:11
  • 1
    Yes, it's right. – Pserr Feb 17 '19 at 18:52
  • 3
    Would it be OK to move everything to one file, say /etc/mysql/my.cnf? I'm only getting confused by the different files and directories under /etc/mysql – Gert-Jan Mar 27 '19 at 12:31
  • 1
    @Gert-Jan Using a monolithic my.cnf is fine; but when you upgrade, you will have to contend with dpkg's desire to rewrite the file. The basic idea is to augment the distro's version of my.cnf with your own add-ons in conf.d/ which should remain untouched thru an upgrade. – ericx Aug 09 '19 at 14:07
  • 1
    @ericx Based on the alphabetical load order, surely your custom options in `conf.d/` are at risk of being overwritten by files in `mysql.conf.d/` though. Doesn't it make more sense to add customisation in a separate file in `mysql.conf.d/` with a name that ensures it gets loaded last (as @Nicolas suggests)? – BadHorsie Oct 21 '20 at 15:50
  • @BadHorsie Yah, you're probably correct. Nowadays I try to drive all mine with configs pushed out by ansible; so it's easy to re-play if something gets overwritten. But I'm still re-using the default config files that come with the install package. – ericx Oct 23 '20 at 17:26
0

The default configuration files in the two subdirectories suggest conf.d is intended for Client config and mysql.conf.d is intended for Server config:

root@ubuntu-focal:~# grep "configuration file" /etc/mysql/conf.d/* etc/mysql/mysql.conf.d/*
/etc/mysql/conf.d/mysql.cnf:# The MySQL  Client configuration file.
/etc/mysql/mysql.conf.d/mysqld.cnf:# The MySQL  Server configuration file.
Jimadine
  • 141
  • 3
  • Relevant: https://salsa.debian.org/mariadb-team/mysql/-/commit/83ae17290118bc65feadf671f48ffab996fbc1d1 – sch Jan 30 '23 at 16:49