Context: I'm porting an opensource server software (and writing associated documentation) from Debian/Ubuntu to CentOS/RHEL.

For the software to run correctly, I need to add a dozen of specific parameters to Mysql configuration (example: increase max_allowed_packet).

From a Debian point of view, I known I can override Mysql's my.cnf by adding a file to /etc/mysql.d, say /etc/mysql.d/my-software.cnf.

My question is: how to do the same correctly on CentOS/RHEL ?

Other infos:

  • I know where mysqld looks for its configuration file thanks to https://dev.mysql.com/doc/refman/5.7/en/option-files.html. But, for CentOS, I don't understand:
    • how NOT to directly edit /etc/my.cnf (that may not be package-update-proof)
    • where to add my specific Mysql parameters
  • Reading the CentOS Mysql init script (/etc/init.d/mysql), I've seen that a /etc/sysconfig/mysqld is sourced, but I don't know how to add configuration parameters.
  • I've search for combinations of override / my.cnf / centos on ServerFault, StackOverflow and also DBA.StackExchange, but found nothing relevant.
  • I make all the tests within a "centos:6" Docker container
  • the software is Asqatasun https://github.com/Asqatasun/Asqatasun
  • 1
    Why are you using centos 6 rather than centos 7? This is just going to add three and a half years of technical debt instantly. – Michael Hampton Sep 22 '16 at 6:14
  • @MichaelHampton to widen the audience, some users still have conservative upgrade policies. But as our base is Debian/Ubuntu, if centos6 is not feasible, we will certainly switch to centos7 – Matthieu FAURE Sep 22 '16 at 6:22
  • 3
    On CentOS 7, you would just stick everything in /etc/my.cnf.d like you do now. This wasn't set up on 6. – Michael Hampton Sep 22 '16 at 6:24
  • 1
    And as for conservative, EL 6 is past the end of Production 1, which is about the time you should stop deploying it for new projects. Doing anything greenfield on EL 6 right now is steadily moving away from "conservative" and toward "insane". – Michael Hampton Sep 22 '16 at 6:27
  • @MichaelHampton I didn't know that Redhat document, really interesting, thanks! I have arguments now, we will switch to 7. – Matthieu FAURE Sep 22 '16 at 6:47

Using strace -e open /some/prog/name, e.g. strace -e open mysql would reveal what places are checked for configuration directives and in what order for each particular OS and a program version. Different programs use different location and sections within a configuration.

As to overriding, you can only be sure that CentOS/RHEL installs and uses /etc/my.cnf. If software your are porting uses libmysqlclient, you may take the path of overriding MYSQL_HOME environmental variable. If not, adding !include /some/location.cnf to [client] section of /etc/my.cnf is still an option.

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.