[Maria-discuss] Upgrade from 10.0.12 -> 10.0.13 changes default config file location behavior; build-time "-DDEFAULT_SYSCONFDIR=" is now ignored ?
I build MariaDB from src. I've been running v10.0.12 (r4252). I've upgraded to v10.0.13 (r4346). My build config always includes cmake .. --debug-output \ -DCMAKE_BUILD_TYPE="Release" \ -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \ -DINSTALL_LAYOUT=STANDALONE \ -DINSTALL_SYSCONFDIR=/usr/local/etc/mariadb.DEFAULT \ -DINSTALL_SYSCONF2DIR=/usr/local/etc/mariadb.DEFAULT/conf.d \ -DDEFAULT_SYSCONFDIR=/usr/local/etc/mariadb \ ... I have always kept my config only in /usr/local/etc/mariadb/my.cnf with no ~/.my.cnf in existence. Launching MariaDB (via systemd) with /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/etc/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/var/db/mariadb --plugin-dir=/usr/local/mariadb/lib/plugin --log-error=/var/log/mariadb/mariadb-err.log --pid-file=/var/cache/mariadb/mariadb.pid --socket=/var/cache/mariadb/mariadb.sock --port=3306 and noting cat ./scripts/CMakeLists.txt ... IF(INSTALL_SYSCONFDIR) SET(sysconfdir ${DEFAULT_SYSCONFDIR}) ELSE() SET(sysconfdir "/etc") ENDIF() ... & cat ./mysys/my_default.c ... /* Which directories are searched for options (and in which order) */ ... /* This structure defines the context that we pass to callback function 'handle_default_option' used in search_default_file to process each option. This context is used if search_default_file was called from load_defaults. */ struct handle_option_ctx ... /** Create the list of default directories. @param alloc MEM_ROOT where the list of directories is stored @details The directories searched, in order, are: - Windows: GetSystemWindowsDirectory() - Windows: GetWindowsDirectory() - Windows: C:/ - Windows: Directory above where the executable is located - Unix: /etc/ or the value of DEFAULT_SYSCONFDIR, if defined - Unix: /etc/mysql/ unless DEFAULT_SYSCONFDIR is defined - ALL: getenv("MYSQL_HOME") - ALL: --defaults-extra-file=<path> (run-time option) - Unix: ~/ On all systems, if a directory is already in the list, it will be moved to the end of the list. This avoids reading defaults files multiple times, while ensuring the correct precedence. @retval NULL Failure (out of memory, probably) @retval other Pointer to NULL-terminated array of default directories */ ... & @ https://mariadb.com/kb/en/mariadb/documentation/getting-started/configuring-... On a Linux, Unix or Mac server, MariaDB looks for the my.cnf file in the following locations: Location Scope /etc/my.cnf Global /etc/mysql/my.cnf Global SYSCONFDIR/my.cnf Global $MYSQL_HOME/my.cnf Server defaults-extra-file File specified with --defaults-extra-file=path, if any /.my.cnf User SYSCONFDIR is the directory specified with the CMake SYSCONFDIR option when MariaDB was built, by default etc under the compiled-in installation directory. with MariaDB v <= 10.0.12, changes to my config have always been correctly picked up, INCLUDING by all mysql client tools. So, for example, if in my.cnf I add ... [client] user = root password = 'XXXXXX' ... then at shell, instead of mysqlshow -u root -p password: XXXXXX I can just mysqlshow and the options as specified are picked up. With MariaDB 10.0.13, the config file is ignored; no changes to it are picked up. The client apps still require cmd line "-u" & "-p", e.g. mysqlshow -u root -p But if I simply cp -af /usr/local/etc/mariadb/my.cnf ~/.my.cnf then, the changes are picked up -- from the ~/.my.cnf location. and just mysqlshow works, as previously. Is this change in behavior intentional? What't the correct, expected/intended behavior? If it's changed, how do I now specify and use the default config file location? Grant
If I strace mysqlshow I see ... stat("/usr/local/etc/mariadb.DEFAULT/my.cnf", {st_mode=S_IFREG|0644, st_size=202, ...}) = 0 open("/usr/local/etc/mariadb.DEFAULT/my.cnf", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=202, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1db94ec000 read(3, "#\n# This group is read both both"..., 4096) = 202 openat(AT_FDCWD, "/etc/my.cnf.d/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4 getdents(4, /* 3 entries */, 32768) = 88 getdents(4, /* 0 entries */, 32768) = 0 close(4) = 0 stat("/etc/my.cnf.d/default_plugins.cnf", {st_mode=S_IFREG|0640, st_size=122, ...}) = 0 open("/etc/my.cnf.d/default_plugins.cnf", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0640, st_size=122, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1db94eb000 read(4, "[server]\n#plugin-load=blackhole="..., 4096) = 122 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7f1db94eb000, 4096) = 0 read(3, "", 4096) = 0 close(3) = 0 munmap(0x7f1db94ec000, 4096) = 0 stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=8792, ...}) = 0 open("/root/.my.cnf", O_RDONLY) = 3 ... Notice, stat("/usr/local/etc/mariadb.DEFAULT/my.cnf", {st_mode=S_IFREG|0644, st_size=202, ...}) = 0 open("/usr/local/etc/mariadb.DEFAULT/my.cnf", O_RDONLY) = 3 then stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=8792, ...}) = 0 open("/root/.my.cnf", O_RDONLY) = 3 is searched. There's no indication at all that the specified dir (as noted in my prior post) -DDEFAULT_SYSCONFDIR=/usr/local/etc/mariadb \ is searched.
Hi, grantksupport! On Aug 12, grantksupport@operamail.com wrote:
I build MariaDB from src.
I've been running v10.0.12 (r4252). I've upgraded to v10.0.13 (r4346).
My build config always includes
cmake .. --debug-output \ -DCMAKE_BUILD_TYPE="Release" \ -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \ -DINSTALL_LAYOUT=STANDALONE \ -DINSTALL_SYSCONFDIR=/usr/local/etc/mariadb.DEFAULT \ -DINSTALL_SYSCONF2DIR=/usr/local/etc/mariadb.DEFAULT/conf.d \ -DDEFAULT_SYSCONFDIR=/usr/local/etc/mariadb \ ...
I have always kept my config only in
/usr/local/etc/mariadb/my.cnf
with no ~/.my.cnf in existence.
Launching MariaDB (via systemd) with
/usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/etc/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/var/db/mariadb --plugin-dir=/usr/local/mariadb/lib/plugin --log-error=/var/log/mariadb/mariadb-err.log --pid-file=/var/cache/mariadb/mariadb.pid --socket=/var/cache/mariadb/mariadb.sock --port=3306
with MariaDB v <= 10.0.12, changes to my config have always been correctly picked up, INCLUDING by all mysql client tools.
So, for example, if in my.cnf I add
... [client] user = root password = 'XXXXXX' ...
then at shell, instead of
mysqlshow -u root -p password: XXXXXX
I can just
mysqlshow
and the options as specified are picked up.
I don't see how this could've been possible. The code doesn't search in the @CMAKE_INSTALL_PREFIX@/etc, and I've just built MariaDB 10.0.12, and tools aren't reading /usr/local/mariadb/etc/my.cnf file: $ mysqldump --help ... Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/mariadb.DEFAULT/my.cnf ~/.my.cnf ... And 10.0.13 didn't change that. Perhaps you've symlinked /usr/local/mariadb/etc/my.cnf to /etc/my.cnf? Because this was changed in 10.0.13, indeed. Before 10.0.13 MariaDB was reading /etc/my.cnf and /etc/mysql/my.cnf unconditionally. Since 10.0.13 it does that only if you didn't specify INSTALL_SYSCONFDIR or DEFAULT_SYSCONFDIR. If you've explicitly specified where your config files are, MariaDB won't look elsewhere, you can "sandbox" it in a dedicated location and know that it won't look outside of it. Regards, Sergei
Hi serg On Tue, Aug 12, 2014, at 07:45 AM, Sergei Golubchik wrote:
Hi, grantksupport! I don't see how this could've been possible. The code doesn't search in the @CMAKE_INSTALL_PREFIX@/etc, and I've just built MariaDB 10.0.12, and tools aren't reading /usr/local/mariadb/etc/my.cnf file:
$ mysqldump --help ... Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/mariadb.DEFAULT/my.cnf ~/.my.cnf ...
And 10.0.13 didn't change that.
here, with *my* 10.0.13, $ mysqldump --help ... Default options are read from the following files in the given order: /usr/local/etc/mariadb.DEFAULT/my.cnf ~/.my.cnf ... You can see from the included ^^^ strace that those are the ONLY two locations checked -- DESPITE having specified all of -DINSTALL_SYSCONFDIR=/usr/local/etc/mariadb.DEFAULT \ -DINSTALL_SYSCONF2DIR=/usr/local/etc/mariadb.DEFAULT/conf.d \ -DDEFAULT_SYSCONFDIR=/usr/local/etc/mariadb \
Perhaps you've symlinked /usr/local/mariadb/etc/my.cnf to /etc/my.cnf? Because this was changed in 10.0.13, indeed.
Before 10.0.13 MariaDB was reading /etc/my.cnf and /etc/mysql/my.cnf unconditionally. Since 10.0.13 it does that only if you didn't specify INSTALL_SYSCONFDIR or DEFAULT_SYSCONFDIR. If you've explicitly specified where your config files are, MariaDB won't look elsewhere, you can "sandbox" it in a dedicated location and know that it won't look outside of it.
So "stuff" *has* changed ... Here, having "explicitly specified where your config files are", it's not that MariaDB x.13 "won't look elsewhere", the issue is that it won't look THERE. "sandbox"-ing *is* what I'm looking for. I.e., I want MariaDB & all client apps to look ONLY in -DDEFAULT_SYSCONFDIR=/usr/local/etc/mariadb What do I need to change to make that happen? Grant
fyi, mysqld -V mysqld Ver 10.0.13-MariaDB for Linux on x86_64 (Source distribution) ls -al /usr/local/etc/mariadb/my.cnf /etc/my.cnf /root/.my.cnf ls: cannot access /etc/my.cnf: No such file or directory ls: cannot access /root/.my.cnf: No such file or directory -rw-r--r--+ 1 root mysql 8.7K Aug 11 17:48 /usr/local/etc/mariadb/my.cnf grep "\[client\]" /usr/local/etc/mariadb/my.cnf -A2 [client] user = root password = 'xxxxxx' mysqlshow mysqlshow: Access denied for user 'root'@'localhost' (using password: NO) ln -sf /usr/local/etc/mariadb/my.cnf /etc/my.cnf mysqlshow mysqlshow: Access denied for user 'root'@'localhost' (using password: NO) rm -f /etc/my.cnf ln -sf /usr/local/etc/mariadb/my.cnf /root/.my.cnf mysqlshow +------------------------------+ | Databases | +------------------------------+ | information_schema | | mysql | | performance_schema | | test | +------------------------------+
per chat in #irc, moved to bug: "search order for my.cnf inconsistent in docs/use, and global override with build-time -DDEFAULT_SYSCONFDIR is ignored" https://mariadb.atlassian.net/browse/MDEV-6565
participants (2)
-
grantksupport@operamail.com
-
Sergei Golubchik