brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: my_print_defaults shows which options your MariaDB server reads from files

Mariadb
~/tips/tip-mariadb-my-print-defaults

my_print_defaults --mysqld

Shows which settings are picked up from all the option files together.

You edit a config file, restart, and nothing changes. Before doubting the setting, check whether the server reads your line at all.

This tool collects the options exactly as the server would from its option files:

my_print_defaults --mysqld

Each option comes out as a command line argument, in the order read. With several files in play, the same setting can appear twice, and the one further down wins. That alone explains plenty of “but I set it” mysteries.

To see which files are searched, and in what order, ask for its help text:

my_print_defaults --help

For the client programs, name their groups instead:

my_print_defaults client mariadb

In a container, run it with docker exec and your container name, which is also a good way to confirm that a mounted .cnf file arrived where you thought it did. If your line is missing, check that the file name ends in .cnf, sits in an included directory and puts the setting under a group header such as [mariadb].

It reads files only. Options given on the server’s command line, such as extra arguments in a compose file, are not listed, and neither are values changed at runtime with SET GLOBAL. For the value in force right now, SHOW GLOBAL VARIABLES LIKE 'max_connections'; has the last word. I’d also keep passwords out of shared output, since a [client] section may contain one.

Further reading: my_print_defaults documentation, Configuring MariaDB with option files

More Mariadb tips ALTER TABLE t ADD COLUMN z INT INVISIBLE; CREATE SEQUENCE s START WITH 100 INCREMENT BY 10; CREATE OR REPLACE TABLE scratch ( mariadb --init-command="SET SESSION sql_mode='STRICT_ALL_TABLES'" mydb mariadb-admin -u root -p extended-status --relative --sleep=10 \ All Mariadb tips (15) All topics

Link