Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
1  
is apparmor active? –  Thomas Berger Oct 17 '12 at 17:11
    
@Thomas Berger OK, so Apparmor is active. The only way around this was to disable Apparmor for MySQL, like so: sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld sudo service apparmor restart This is a development machine, so this solution is fine. However, if I wanted to distribute config files across servers like this in a live environment I wouldn't be happy with this solution. Any other ideas? –  HenryHayes Oct 18 '12 at 11:04

3 Answers 3

It may be caused by apparmor which is enabled for mysqld by default from ubuntu 9.0.4. Please see http://en.wikipedia.org/wiki/AppArmor .

  • You can modify site-specific additions in /etc/apparmor.d/local/. I've suffered the same problem and edited /etc/apparmor.d/local/usr.sbin.mysqld to make it work. Be aware of the last comma in the policy file.

    # Site-specific additions and overrides for usr.sbin.mysqld.
    # For more details, please see /etc/apparmor.d/local/README.
    
    # vim:syntax=apparmor
    
    /etc/mysql/conf.d/* rl,
    @{HOMEDIRS}/** rwk,
    
  • After editing /etc/apparmor.d/local/usr.sbin.mysqld, restart apparmor service by service apparmor restart. There should be no error or warning about /etc/apparmor.d/local/usr.sbin.mysqld .
  • In my case, I wanted to use datadir and site-specific my.cnf located in users's home directory.
share|improve this 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.

share|improve this answer

Apparmor does not know anything about the new location of the my.cnf

The MySQL Server follows the symlink and tries to open the destination. But apparmor denies this.

To fix the problem, you have to add the path to the my.cnf to /etc/apparmor.d/usr.sbin.mysqld

share|improve this answer
    
Potentially the file could be anywhere on a user's development machine. That's the reason I'm using a symlink. I tied to add the location of the symlink as follows: /etc/mysql/conf.d/symlinked-file.cnf directly underneath the /etc/mysql/conf.d/* line however, this did not work. –  HenryHayes Oct 18 '12 at 11:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.