Bug #75932 mysqld_safe on CentOS 6 ignores [mysqld_safe] configuration option group
Submitted: 17 Feb 2015 15:14 Modified: 20 Feb 2015 20:38
Reporter: Geoff Montee Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.6 OS:Any
Assigned to: CPU Architecture:Any

[17 Feb 2015 15:14] Geoff Montee
Description:
mysqld_safe included in the MySQL Community 5.6 packages for CentOS 6 ignores configuration options in the [mysqld_safe] section of my.cnf.

Here are the packages I'm using:

[gmontee@localhost ~]$ yum list "mysql-community*"
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.sanctuaryhost.com
 * epel: mirrors.einstein.yu.edu
 * extras: mirror.lug.udel.edu
 * updates: mirror.symnds.com
Installed Packages
mysql-community-client.x86_64                   5.6.23-2.el6           @MySQL5.6
mysql-community-common.x86_64                   5.6.23-2.el6           @MySQL5.6
mysql-community-devel.x86_64                    5.6.23-2.el6           @MySQL5.6
mysql-community-libs.x86_64                     5.6.23-2.el6           @MySQL5.6
mysql-community-server.x86_64                   5.6.23-2.el6           @MySQL5.6
Available Packages
mysql-community-bench.x86_64                    5.6.23-2.el6           MySQL5.6 
mysql-community-client.i686                     5.6.23-2.el6           MySQL5.6 
mysql-community-common.i686                     5.6.23-2.el6           MySQL5.6 
mysql-community-devel.i686                      5.6.23-2.el6           MySQL5.6 
mysql-community-embedded.i686                   5.6.23-2.el6           MySQL5.6 
mysql-community-embedded.x86_64                 5.6.23-2.el6           MySQL5.6 
mysql-community-embedded-devel.i686             5.6.23-2.el6           MySQL5.6 
mysql-community-embedded-devel.x86_64           5.6.23-2.el6           MySQL5.6 
mysql-community-libs.i686                       5.6.23-2.el6           MySQL5.6 
mysql-community-libs-compat.i686                5.6.23-2.el6           MySQL5.6 
mysql-community-libs-compat.x86_64              5.6.23-2.el6           MySQL5.6 
mysql-community-release.noarch                  el6-5                  MySQL5.6 
mysql-community-test.x86_64                     5.6.23-2.el6           MySQL5.6 
[gmontee@localhost ~]$ rpm -q --file /etc/init.d/mysqld
mysql-community-server-5.6.23-2.el6.x86_64

How to repeat:
The easiest way to see if a section is being ignored is to define an option that should cause the server to abort startup.

So let's do that for [mysqld_safe]:

[gmontee@localhost ~]$ sudo tee /etc/my.cnf <<EOF
> [mysqld_safe]
> bad-option
> EOF
[mysqld_safe]
bad-option

And now try to start the server:

[gmontee@localhost ~]$ sudo mysqld_safe --user=mysql &
[1] 12524
[gmontee@localhost ~]$ 150217 10:06:05 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
150217 10:06:05 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

And it works:

[gmontee@localhost ~]$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> \q
Bye

Now stop the server, and put the bad option in [mysqld] instead:

[gmontee@localhost ~]$ mysqladmin -u root shutdown
150217 10:07:01 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended

[1]+  Done                    sudo mysqld_safe --user=mysql
[gmontee@localhost ~]$ sudo tee /etc/my.cnf <<EOF
> [mysqld]
> bad-option
> EOF
[mysqld]
bad-option

Now start the server the same way and it fails as expected:

[gmontee@localhost ~]$ 150217 10:08:11 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
150217 10:08:11 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150217 10:08:13 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended

[1]+  Done                    sudo mysqld_safe --user=mysql
[gmontee@localhost ~]$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Suggested fix:
mysqld_safe should use options specified in the [mysqld_safe] group.
[17 Feb 2015 16:04] Geoff Montee
Actually, it seems that I have misinterpreted how mysqld_safe works. According to the documentation:

http://dev.mysql.com/doc/refman/5.6/en/mysqld-safe.html

"Options unknown to mysqld_safe are passed to mysqld if they are specified on the command line, but ignored if they are specified in the [mysqld_safe] group of an option file."

In my opinion, it would make sense if all unknown options were passed to mysqld, rather than get completely ignored. It seems counter-intuitive for option file settings and command-line settings to be treated differently by mysqld_safe.
[20 Feb 2015 20:38] Sveta Smirnova
Thank you for the report.

Closed as "Not a Bug", because last comment.