CentOS - Percona MySQL - Not Reading /etc/my.cnf

I've compiled Percona 5.5 on my CentOS 6.1 server and it starts fine, however it doesn't appear to be reading my /etc/my.cnf file.

# In /etc/my.cnf
character_set_server = utf8
collation_server     = utf8_general_ci

mysql> show variables like 'character_set_server';
+----------------------+--------+
| Variable_name        | Value  |
+----------------------+--------+
| character_set_server | latin1 |
+----------------------+--------+
1 row in set (0.00 sec)

Here, I expect to see a value of 'utf8', not latin1.

Currently the /etc/my.cnf set as a symbolic link pointed to a my.cnf file which is currently in version control, so it looks like:

root@host ~/MyFile/Setup # -> ls /etc/my.cnf
lrwxrwxrwx. 1 root root 64 Dec 17 19:05 /etc/my.cnf -> /home/src/config/current/sys/etc/mysql/prod/confs-enabled/my.cnf

Upon some initial googling, it seems that I need to specifically set the path of the my.cnf file using the --defaults-file=/etc/my.cnf, flag. Which isn't currently being set through the CentOS daemon script:

ps auxfw > tmp.txt
vi tmp.txt
root     11798  0.0  0.1 106044  1488 pts/0    S    19:09   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/host.localdomain.pid
mysql    11875  0.1  4.3 499560 43936 pts/0    Sl   19:09   0:00  \_ /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/host.localdomain.err --pid-file=/var/lib/mysql/host.localdomain.pid

So my question is, how do I add the ability to pass the --defaults-file=/etc/my.cnf flag to /etc/init.d/mysql daemon script?

Thanks.

-- UPDATE --

The problem appears to be because I have selinux policy set to enforcing, and trying to symlink my.cnf. Consider the following:

lrwxrwxrwx. 1 root root 72 Feb  7 05:02 my.cnf -> /home/src/config/current/sys/etc/mysql/prod/confs-available/my-large.cnf

And the /home/src perms look like:

drwxrwxr-x. src  src  unconfined_u:object_r:user_home_t:s0 config

If I copy the same exact file to /etc, it works, and if I disable selinux, it also works. So it has to do with the fact that mysql is trying to access /home/src.

Also, I did an audit2why, and it responded with:

Feb  8 17:32:20 app-mldrinks-aa-1 kernel: type=1400 audit(1328722340.203:17): avc:  denied  { read } for  pid=2109 comm="mysqld" name="xvda" dev=devtmpfs ino=5801 scontext=unconfined_u:system_r:mysqld_t:s0 tcontext=system_u:object_r:fixed_disk_device_t:s0 tclass=blk_file

Was caused by:
    Missing type enforcement (TE) allow rule.

    You can use audit2allow to generate a loadable module to allow this access.

Is there a way to make this work without having to create a custom selinux module? I can't change the context type of /home/src/config/current to mysqld_db_t because everytime I push a config change a new directory will be created with user_home_t, which will contain the latest changes.


Solution 1:

Maybe you could get at it the other way - try to find which my.cnf is percona trying to read.

ie. mysqld --help --verbose | head -n 30 and look for something like

Default options are read from the following files in the given order:
/etc/mysql/my.cnf ~/.my.cnf