Bug #74814 mysqld_multi does not respect [mysqld*] section in installdir/etc/my.cnf
Submitted: 12 Nov 2014 11:01 Modified: 9 Apr 2015 12:29
Reporter: Georgi Iovchev Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.5.40, 5.5.43, 5.6.23 OS:Linux (CentOS 6.6)
Assigned to: CPU Architecture:Any
Tags: mysqld_multi

[12 Nov 2014 11:01] Georgi Iovchev
Description:
I have build MySQL from sources with option:
-DCMAKE_INSTALL_PREFIX=/opt/mysql/mysql5540

When I run whatever command (for example /opt/mysql/mysql5540/bin/mysqld) with --help --verbose to check what configuration files will be used it reports:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /opt/mysql/mysql5540/etc/my.cnf ~/.my.cnf

I have chosen to use /opt/mysql/mysql5540/etc/my.cnf.
However it seems that mysqld_multi does not completely respect  file.
[mysqld_multi]
mysqld     = /opt/mysql/mysql5540/bin/mysqld_safe
mysqladmin = /opt/mysql/mysql5540/bin/mysqladmin
user       = multi_admin
password   = multipass
log=/var/log/mysqld_multi_55.log

[mysqld1]
bind-address = mysql
datadir      = /opt/mysql/mysql5540/data
pid-file     = /opt/mysql/mysql5540/var/mysql.pid
log-error    = /opt/mysql/mysql5540/var/mysql.err
socket       = /opt/mysql/mysql5540/var/mysql.sock

When I try to get status report I receive error:
# /opt/mysql/mysql5540/bin/mysqld_multi report
Reporting MySQL servers
No groups to be reported (check your GNRs)

It seems that it respects [mysqld_multi] section, because the errors are written in the configured log (/var/log/mysqld_multi_55.log). But it does not respect [mysqld1] section.

If I put [mysqld1] in /etc/my.cnf - mysqld_multi works fine, but I don't want to use /etc/my.cnf, because on this server I have multiple mysql versions and I prefer to use different config file per installation.

For information only - this problem does not exist with 5.0.96 mysql mysqld_multi.

How to repeat:
Build MySQL 5.5.40 from sources using not standard location
-DCMAKE_INSTALL_PREFIX=/myinstalldir
http://dev.mysql.com/doc/refman/5.5/en/installing-source-distribution.html

Create configuration file /myinstalldir/etc/my.cnf containing empty section
[mysqld1]

Execute:
( PATH=/myinstalldir/bin:$PATH ; mysqld_multi report )

You will receive error:
No groups to be reported (check your GNRs)
[12 Nov 2014 11:21] Georgi Iovchev
The problem is that in mysqld_multi on line 487 it was missing "etc" in the path:
'/opt/mysql/mysql5540/my.cnf'

I changed to
'/opt/mysql/mysql5540/etc/my.cnf'

In sources I believe that in file scripts/mysqld_multi same line (487):
               '@sysconfdir@/my.cnf',

also should be changed to:
               '@sysconfdir@/etc/my.cnf',

@Devs, please make this correction in future releases :)
[9 Apr 2015 12:29] MySQL Verification Team
Hello Georgi Iovchev,

Thank you for the report.
Observed this with 5.5.43 source build.

Thanks,
Umesh
[9 Apr 2015 12:29] MySQL Verification Team
// OS and source details

[root@cluster-repo mysql-5.5.43]# cat /etc/*release
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Oracle Linux Server release 6.6
Red Hat Enterprise Linux Server release 6.6 (Santiago)
Oracle Linux Server release 6.6

[root@cluster-repo archive]# md5sum mysql-5.5.43.tar.gz
d77cc87df51af3f79b005d90e26879c1  mysql-5.5.43.tar.gz

[root@cluster-repo mysql-5.5.43]# cmake . -DCMAKE_INSTALL_PREFIX=/data/ushastry/server/source_build/mysql-5.5.43
-- Running cmake version 2.8.12.2
-- Found Git: /usr/bin/git (found version "1.7.1")
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for SHM_HUGETLB
-- Looking for SHM_HUGETLB - found
-- MySQL 5.5.43

.
-- Configuring done
-- Generating done
-- Build files have been written to: /data/ushastry/server/source_build/mysql-5.5.43

[root@cluster-repo mysql-5.5.43]# make && make install

###

[root@cluster-repo mysql-5.5.43]# bin/mysqld --verbose --help|grep cnf
150411 19:07:34 [Note] bin/mysqld (mysqld 5.5.43) starting as process 9165 ...
..
/etc/my.cnf /etc/mysql/my.cnf /data/ushastry/server/source_build/mysql-5.5.43/etc/my.cnf ~/.my.cnf
                      my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default
[root@cluster-repo mysql-5.5.43]#

## mysqld_multi conf file in /data/ushastry/server/source_build/mysql-5.5.43/etc/my.cnf

[mysqld_multi]
mysqld     = /data/ushastry/server/source_build/mysql-5.5.43/bin/mysqld_safe
mysqladmin = /data/ushastry/server/source_build/mysql-5.5.43/bin/mysqladmin
user       = multi
password   = pass
log=/data/ushastry/server/source_build/mysql-5.5.43/log/mysqld_multi.log

[mysqld3306]
socket     = /tmp/mysql_3306.sock
port       = 3306
pid-file   = /data/ushastry/server/source_build/mysql-5.5.43/run/3306.pid
datadir    = /data/ushastry/server/source_build/mysql-5.5.43/3306
user       = mysql

[mysqld3307]
socket     = /tmp/mysql_3307.sock
port       = 3307
pid-file   = /data/ushastry/server/source_build/mysql-5.5.43/run/3307.pid
datadir    = /data/ushastry/server/source_build/mysql-5.5.43/3307
user       = mysql

#######

[root@cluster-repo mysql-5.5.43]# bin/mysqld_multi report
Reporting MySQL servers
No groups to be reported (check your GNRs)

## When I provide --defaults-file then it works

[root@cluster-repo mysql-5.5.43]# bin/mysqld_multi --defaults-file=etc/my.cnf report
Reporting MySQL servers
MySQL server from group: mysqld3306 is not running
MySQL server from group: mysqld3307 is not running

## scripts/mysqld_multi - etc is missing in 487

    483   my %seen;  # Don't list the same file more than once
    484   return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ }
    485               ('/etc/my.cnf',
    486                '/etc/mysql/my.cnf',
    487                '/data/ushastry/server/source_build/mysql-5.5.43/my.cnf',
    488                ($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
    489                $opt{'extra-file'},
    490                ($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));

## After changing /data/ushastry/server/source_build/mysql-5.5.43/my.cnf to /data/ushastry/server/source_build/mysql-5.5.43//etc/my.cnf

[root@cluster-repo mysql-5.5.43]# bin/mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3306 is not running
MySQL server from group: mysqld3307 is not running
[9 Apr 2015 13:03] MySQL Verification Team
//5.6.23

// OS and source details

[root@cluster-repo mysql-5.5.43]# cat /etc/*release
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Oracle Linux Server release 6.6
Red Hat Enterprise Linux Server release 6.6 (Santiago)
Oracle Linux Server release 6.6

[root@cluster-repo archive]# md5sum mysql-5.6.23.tar.gz
60344f26eae136a267a0277407926e79  mysql-5.6.23.tar.gz

// build
[root@cluster-repo mysql-5.6.23]# cmake . -DCMAKE_INSTALL_PREFIX=/data/ushastry/server/source_build/mysql-5.6.23/
-- Running cmake version 2.8.12.2
-- Found Git: /usr/bin/git (found version "1.7.1")
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
..
.
-- Configuring done
-- Generating done
-- Build files have been written to: /data/ushastry/server/source_build/mysql-5.6.23

[root@cluster-repo mysql-5.6.23]# make && make install
Scanning dependencies of target INFO_BIN
[  0%] Built target INFO_BIN
..

###

[root@cluster-repo mysql-5.6.23]# bin/mysqld --verbose --help|grep cnf
..
/etc/my.cnf /etc/mysql/my.cnf /data/ushastry/server/source_build/mysql-5.6.23/etc/my.cnf ~/.my.cnf
                      my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default

## mysqld_multi conf file in /data/ushastry/server/source_build/mysql-5.6.23/etc/my.cnf

[mysqld_multi]
mysqld     = /data/ushastry/server/source_build/mysql-5.6.23/bin/mysqld_safe
mysqladmin = /data/ushastry/server/source_build/mysql-5.6.23/bin/mysqladmin
user       = multi
password   = pass
log=/data/ushastry/server/source_build/mysql-5.6.23/log/mysqld_multi.log

[mysqld3306]
socket     = /tmp/mysql_3306.sock
port       = 3306
pid-file   = /data/ushastry/server/source_build/mysql-5.6.23/run/3306.pid
datadir    = /data/ushastry/server/source_build/mysql-5.6.23/3306
user       = mysql

[mysqld3307]
socket     = /tmp/mysql_3307.sock
port       = 3307
pid-file   = /data/ushastry/server/source_build/mysql-5.6.23/run/3307.pid
datadir    = /data/ushastry/server/source_build/mysql-5.6.23/3307
user       = mysql

#######

[root@cluster-repo mysql-5.6.23]# bin/mysqld_multi report
Reporting MySQL servers
No groups to be reported (check your GNRs)

## When I provide --defaults-file then it works

[root@cluster-repo mysql-5.6.23]# bin/mysqld_multi --defaults-file=etc/my.cnf report
Reporting MySQL servers
MySQL server from group: mysqld3306 is not running
MySQL server from group: mysqld3307 is not running

## scripts/mysqld_multi - etc is missing in 578

    574   my %seen;  # Don't list the same file more than once
    575   return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ }
    576               ('/etc/my.cnf',
    577                '/etc/mysql/my.cnf',
    578                '/data/ushastry/server/source_build/mysql-5.6.23/my.cnf',
    579                ($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
    580                $opt{'extra-file'},
    581                ($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));
    582 }

// included correct path

[root@cluster-repo mysql-5.6.23]# bin/mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3306 is not running
MySQL server from group: mysqld3307 is not running