Description:
mysqlbinlog, mysqltest, mysqlslap are failing to start if default-character-set option is set in [client] section (e.g. default-character-set=utf8) due to "unknown variable" error.
As MySQL manual suggests to put "default-character-set" to either [client] or [mysql] section for client setup, I'm not sure it's really a bug.
But definitely all mentioned client programs read [client] section of .cnf file for connection settings values, but not all recognize variables native for [client] section:
Here are some source code cuts with my comments
client/mysqladmin.cc:static const char *load_default_groups[]= { "mysqladmin","client",0 }; /* "default-character-set" present */
client/mysqlbinlog.cc:static const char *load_default_groups[]= { "mysqlbinlog","client",0 }; /* mysqlbinlog: unknown variable 'default-character-set=utf8' */
client/mysqldump.c:static const char *load_default_groups[]= { "mysqldump","client",0 }; /* "default-character-set" present */
client/mysqlimport.c:static const char *load_default_groups[]= { "mysqlimport","client",0 }; /* "default-character-set" present */
client/mysqlshow.c:static const char *load_default_groups[]= { "mysqlshow","client",0 }; /* "default-character-set" present */
client/mysqlslap.cc:static const char *load_default_groups[]= { "mysqlslap","client",0 }; /* mysqlslap: unknown variable 'default-character-set=utf8' */
client/mysqltest.cc:static const char *load_default_groups[]= { "mysqltest", "client", 0 }; /* mysqltest: unknown variable 'default-character-set=utf8' */
So, please, check this and share your opinion, whether [client] setup section is an appropriate place to store "default-character-set" and which of suggested solutions will fit (if any).
How to repeat:
Run mentioned utilities:
[root@host-208 user]# mysqlbinlog
mysqlbinlog: [ERROR] unknown variable 'default-character-set=utf8'
[root@host-208 user]# mysqltest
mysqltest: [ERROR] unknown variable 'default-character-set=utf8'
[root@host-208 user]# mysqlslap
mysqlslap: [ERROR] unknown variable 'default-character-set=utf8'
while .cnf file contains "default-character-set = utf8" in [client] section
[root@host-208 user]# cat /etc/my.cnf.d/client.cnf
[client]
user = mysql
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
default-character-set = utf8
Version info:
[root@host-208 user]# mysqld --help
mysqld Ver 5.7.21-alt2 for Linux on x86_64 ((ALT))
[root@host-208 user]# mysql --help
mysql Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper
Suggested fix:
There are at least two ways to avoid described behaviour:
1. To put variables unrecognized by mentioned programs into target utils' respective setup section section (e.g. [mysql], [mysqldump]) and avoid putting them into [mysqlbinlog], ... etc. sections. This should be mentioned in user manual then.
2. Register widely used variables of [client] section in mysqlbinlog, mysqltest, mysqlslap code to provide compatibility as it is made in mysql_upgrade code:
client/upgrade/program.cc:const char *load_default_groups[]=
{
"client", /* Read settings how to connect to server */
"mysql_upgrade", /* Read special settings for mysql_upgrade*/
0
};
[root@host-208 user]# mysql_upgrade --help
....
--default-character-set=name
Not used by mysql_upgrade. Only for backward
compatibility.
....