Bug #74551 Dots in file names of configuration files
Submitted: 24 Oct 2014 15:11 Modified: 25 Oct 2014 17:15
Reporter: Geoff Montee Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.6.21 OS:Linux
Assigned to: CPU Architecture:Any

[24 Oct 2014 15:11] Geoff Montee
Description:
If an includedir directive like the following is added to /etc/my.cnf:

!includedir /home/mysql/conf

MySQL should load any configuration variables from files in that directory if the file name ends with '.cnf' according to the documentation:

http://dev.mysql.com/doc/refman/5.6/en/option-files.html

The problem I ran into is that MySQL appears to do the comparison based on the first dot character ('.') that appears in the filename. If I have a file with a full path like this:

/home/mysql/conf/mysql5.6.cnf

MySQL appears to think that the extension of the file is '.6.cnf', rather than '.cnf', so it won't load configuration variables from it.

How to repeat:
Add an includedir directive to my.cnf.

In the directory named in the includedir directive, add a file  with a name that adds in .cnf, but also has at least one additional dot character ('.') in the name.

Suggested fix:
Perform the comparison by seeing that the file name ends with '.cnf', rather than comparing against the string that appears after the first dot character ('.').
[25 Oct 2014 0:05] MySQL Verification Team
I couldn't repeat on CentOS 6.5:

[miguel@cuzcatlan ~]$ cat /etc/my.cnf
!includedir /home/miguel/dbs/
[miguel@cuzcatlan ~]$ cat /home/miguel/dbs/mysql5.6.cnf
[mysqld]
datadir=/home/miguel/dbs/5.6/data
basedir=/home/miguel/dbs/5.6

[miguel@cuzcatlan 5.6]$ bin/mysqld
2014-10-24 21:59:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-10-24 21:59:18 5018 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)

2014-10-24 21:59:18 5018 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)

2014-10-24 21:59:18 5018 [Note] Plugin 'FEDERATED' is disabled.
2014-10-24 21:59:18 5018 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-10-24 21:59:18 7fcbcfc62720 InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!
2014-10-24 21:59:18 7fcbcfc62720 InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!
2014-10-24 21:59:18 5018 [Note] InnoDB: The InnoDB memory heap is disabled
2014-10-24 21:59:18 5018 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-10-24 21:59:18 5018 [Note] InnoDB: Memory barrier is not used
2014-10-24 21:59:18 5018 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-10-24 21:59:18 5018 [Note] InnoDB: Using CPU crc32 instructions
2014-10-24 21:59:18 5018 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-10-24 21:59:18 5018 [Note] InnoDB: Completed initialization of buffer pool
2014-10-24 21:59:18 5018 [Note] InnoDB: Highest supported file format is Barracuda.
2014-10-24 21:59:19 5018 [Note] InnoDB: 128 rollback segment(s) are active.
2014-10-24 21:59:19 5018 [Note] InnoDB: Waiting for purge to start
2014-10-24 21:59:19 5018 [Note] InnoDB: 5.6.22 started; log sequence number 2326919
2014-10-24 21:59:19 5018 [Note] Server hostname (bind-address): '*'; port: 3306
2014-10-24 21:59:19 5018 [Note] IPv6 is available.
2014-10-24 21:59:19 5018 [Note]   - '::' resolves to '::';
2014-10-24 21:59:19 5018 [Note] Server socket created on IP: '::'.
2014-10-24 21:59:19 5018 [Note] Event Scheduler: Loaded 0 events
2014-10-24 21:59:19 5018 [Note] bin/mysqld: ready for connections.
Version: '5.6.22-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution

Please double check. Thanks.
[25 Oct 2014 14:28] Geoff Montee
The easiest way I've found to reproduce this by adding options to the configuration files in the includedir that should cause MySQL to abort startup. If MySQL ignores the configuration file, it will still start successfully:

[root@new-host ~]# rpm -qf /usr/sbin/mysqld
mysql-community-server-5.6.21-2.el6.x86_64
[root@new-host ~]# cat /etc/centos-release 
CentOS release 6.5 (Final)
[root@new-host ~]# mkdir -p /home/mysql
[root@new-host ~]# chown mysql:mysql /home/mysql
[root@new-host ~]# mkdir -p /home/mysql/conf
[root@new-host ~]# chown mysql:mysql /home/mysql/conf
[root@new-host ~]# cat >> /etc/my.cnf
!includedir /home/mysql/conf
[root@new-host ~]# cat > /home/mysql/conf/mysql56.cnf
[mysqld]
bad_option
[root@new-host ~]# /usr/sbin/mysqld --user=mysql 2>&1 | grep "ERROR" &
[2] 14830
2014-10-25 10:19:18 14829 [ERROR] /usr/sbin/mysqld: unknown option '--bad_option'
2014-10-25 10:19:18 14829 [ERROR] Aborting

[2]-  Done                    /usr/sbin/mysqld --user=mysql 2>&1 | grep "ERROR"
[root@new-host ~]# rm -f /home/mysql/conf/mysql56.cnf
[root@new-host ~]# cat > /home/mysql/conf/mysql5.6.cnf
[mysqld]
bad_option
[root@new-host ~]# /usr/sbin/mysqld --user=mysql 2>&1 | grep "ERROR" &
[2] 14859
[root@new-host ~]# ps -elf | grep "mysql"
4 S mysql    14858  2237  4  80   0 - 252727 poll_s 10:20 pts/0   00:00:00 /usr/sbin/mysqld --user=mysql
0 S root     14882  2237  0  80   0 - 25814 pipe_w 10:20 pts/0    00:00:00 grep mysql
[root@new-host ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
[25 Oct 2014 17:15] MySQL Verification Team
Thank you for the feedback.