robjbrain robjbrain - 1 month ago 6
MySQL Question

MySQL not picking up symlinked cnf changes in 5.7.13 on Ubuntu 16.04

EDIT: I may have found what might be part of the issue, further edit at the bottom.

I've got a new server setup running mysql everything seems to be okay. Except whenever I use show variables the configuration settings I can see in my .cnf file are not being shown and what appear to be general defaults are being shown. So it would appear while I can use mysql just fine, the settings are all just the defaults.

I am trying to figure out why my .cnf is not being used. I have taken a number of steps to check that it is definitely being loaded and these are laid out below. Once I am sure it is being loaded I am at a loss as to how to explain why my settings aren't being used. Any help would be greatly appreciated.

The location of my cnf file is this:


I have attempted to verify that this is what is being used by the following:

sudo /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

does not exist

is a symlink to

is a symlink to


!includedir /etc/mysql/conf.d/

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

is a directory that contains:



is empty so presumably isn’t doing anything

is a directory that contains:




is a symlink to

is my conf file which I expect it to be using.

So I cannot see the problem it looks like it should be using my config.

In a second attempt to verify that this .cnf is being used I used
strace mysql
. My file was listed and opened along with the other paths I just listed above.

stat("/etc/mysql/mysql.conf.d/mysqld.cnf", {st_mode=S_IFREG|0664, st_size=2262, ...}) = 0
open("/etc/mysql/mysql.conf.d/mysqld.cnf", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0664, st_size=2262, ...}) = 0
read(4, "# Generated by Percona Configura"..., 4096) = 2262
read(4, "", 4096) = 0
close(4) = 0 close(4)

Again it looks like it should be using the .cnf file.

Can anyone offer any insight into why it's not?

EDIT: I've just done a
strace mysqld
instead of
strace mysql
and I get a permission error on my .cnf file. This could be the problem. But I don't understand enough about the difference between mysql and mysqld can anyone explain?

stat("/etc/mysql/mysql.conf.d/mysqld.cnf", {st_mode=S_IFREG|0664, st_size=3218, ...}) = 0
open("/etc/mysql/mysql.conf.d/mysqld.cnf", O_RDONLY) = -1 EACCES (Permission denied)


This was caused and resolved by apparmor

Ubuntu comes with something called AppArmor, a kernel-integrated application security system that controls how applications can access the file system. Source: Oracle Article

If you put the .cnf in a custom location, you need to give mysql permissions to access that directory. In my case I needed to edit this /etc/apparmor.d/local/usr.sbin.mysqld with the following:

/home/{my_username}/conf/mysqld.cnf r

You could also use:

/home/{my_username}/conf/* r

To give it access to the whole directory.