8

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?

0
2

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

6
  • 4
    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
  • 2
    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 9 '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
5

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.

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.

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.