Description:
mysqlmanager does not respect the default config file path set at compile time with --sysconfdir, because it builds with its own hardcoded DEFAULT_CONFIG_FILE flag.
see server-tools/instance-manager/Makefile.am:36
and server-tools/instance-manager/options.cc:45
All other binaries use a basename passed to load_defaults() which allow to search in various defaults paths including the compile-time --sysconfdir path.
E.g.:
my_print_defaults.c use "my" as a default config file because load_defaults use it as a basename when searching the config file in the default directories (including the in the --sysconfdir path).
When an absolute path is hardcoded like in the current mysql manager source (i.e. '/etc/my.cnf'), load_defaults() doesn't look for alternates paths, but only tries to load that only file.
How to repeat:
Compile mysql from sources with the --sysconfdir option to an alternate path like /etc/mysql
Create a my.cnf config file with a [manager] customized section in that alternate path
Start mysqlmanager --help: The config file is not read, confirmed with strace.
mysqlmanager --defaults-file=/etc/mysql/my.cnf works fine.
Suggested fix:
mysqlmanager --defaults-file= is not really a fix because all the MySQL binaries are supposed to find the right defaults path automatically: binaries use the load_defaults function, and scripts call the my_print_defaults binary.
A very simple fix would be to let load_defaults() do its job finding the correct config file by passing the "my" basename as the first argument instead of a hardcoded path.
There are 2 possible ways to fix this and they do basically the same thing: replace the "/etc/my.cnf" hardcoded path with the "my" basename.
Fix #1 (the dirty one): Change the DEFAULT_CONFIG_FILE compile flag
Patch:
=====================================================================
--- Makefile.am.orig 2008-08-04 16:30:04.000000000 +0200
+++ Makefile.am 2008-08-04 16:18:12.000000000 +0200
@@ -33,7 +33,7 @@
-DDEFAULT_SOCKET_FILE_NAME="/tmp/mysqlmanager.sock" \
-DDEFAULT_PASSWORD_FILE_NAME="/etc/mysqlmanager.passwd" \
-DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
- -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \
+ -DDEFAULT_CONFIG_FILE="my" \
-DPROTOCOL_VERSION=@PROTOCOL_VERSION@
liboptions_la_SOURCES= options.h options.cc priv.h priv.cc
=====================================================================
Then run automake/autoconf to rebuild Makefile.in
Fix #2 (the neat one): Remove that useless compile flag and hardcode the "my" basename directly in the source (like in the my_print_defaults source)
Patch:
=====================================================================
--- Makefile.am.orig 2008-08-04 16:30:04.000000000 +0200
+++ Makefile.am 2008-08-04 16:32:04.000000000 +0200
@@ -33,7 +33,6 @@
-DDEFAULT_SOCKET_FILE_NAME="/tmp/mysqlmanager.sock" \
-DDEFAULT_PASSWORD_FILE_NAME="/etc/mysqlmanager.passwd" \
-DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
- -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \
-DPROTOCOL_VERSION=@PROTOCOL_VERSION@
liboptions_la_SOURCES= options.h options.cc priv.h priv.cc
--- options.cc.orig 2008-08-04 16:33:25.000000000 +0200
+++ options.cc 2008-08-04 16:33:02.000000000 +0200
@@ -42,7 +42,7 @@
const char *Options::user= 0; /* No default value */
const char *default_password_file_name= QUOTE(DEFAULT_PASSWORD_FILE_NAME);
const char *default_log_file_name= QUOTE(DEFAULT_LOG_FILE_NAME);
-const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE);
+const char *Options::config_file= "my";
const char *Options::angel_pid_file_name= NULL;
const char *Options::socket_file_name= QUOTE(DEFAULT_SOCKET_FILE_NAME);
#endif
=====================================================================
Then run automake/autoconf to rebuild Makefile.in