MySQL Not Reading Symlinks for Options Files my.cnf

HenryHayes asked:

I’m running MySQL 5.5 on Ubuntu.

There is a my.cnf file in /etc/mysql/ where I would expect it to be. – Great!

For debian installations of mysql it is recommended that you do not edit the my.cnf file. There is an IncludeDir directive in the /etc/mysql/my.cnf file to look in the /etc/mysql/conf.d/ folder for more options files.

When I place this a file here:

/etc/mysql/conf.d/my-local.cnf

MySQL reads the file and overrides anything in /etc/mysql/my.cnf.

Great! 🙂

Here’s the problem:

I keep my local copy of the /etc/mysql/conf.d/my-local.cnf file in source control and want to update it periodically for the whole team. So, my solution is to symlink it:

cd /etc/mysql/conf.d/
ln -s /path/to/my/my-local.cnf my-local.cnf

MySQL does not read this symlink.

I have verified the following:

  • Both the physical file and the symlink have the .cnf file extension as per mysql’s manual.
  • The mysql user has access to this file
  • Every user has access to this file
  • The mysql user has access to the symlink
  • Every user has access to the symlink

So to summarise, MySQL will read and parse when there is a physical file in the /etc/mysql/conf.d/ folder. Mysql will not read a symlink in this folder.

Any ideas anyone? Could this be a debian/ubuntu issue?

A similar, but unresolved and slightly different problem was outlined here.

My answer:


Some possibilities come to mind:

  • Create the symlink in the other direction, i.e.

    /home/developer/my-local.cnf -> /etc/mysql/conf.d/my-local.cnf
    
  • Use a hard link instead.

  • Put /etc under version control using a tool such as etckeeper.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.