Skip to content

fix(mariadb,mysql plugin): ignore /etc/mysql config files, for better isolation (#2904)#2906

Open
jefft wants to merge 1 commit into
jetify-com:mainfrom
jefft:jefft/mysql-plugin-ignore-etc-mysql
Open

fix(mariadb,mysql plugin): ignore /etc/mysql config files, for better isolation (#2904)#2906
jefft wants to merge 1 commit into
jetify-com:mainfrom
jefft:jefft/mysql-plugin-ignore-etc-mysql

Conversation

@jefft

@jefft jefft commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #2904.

By default, mariadbd reads /etc/mysql/mariadb.cnf, and if the system has another version of MariaDB installed, those config files can cause the Devbox mariadbd to fail (e.g. requesting loading plugins not available).

Devbox services ought to be isolated from their environment. This commit causes devbox mariadbd (and mysqld) to only read from $MYSQL_CONF (typically devbox.d/mariadb/my.cnf).

Additionally, wrap the client/admin binaries (mariadb, mariadb-admin, mariadb-dump, mysqldump, mysql, mysqladmin) with --defaults-file and --socket so they also ignore /etc/mysql and connect to the correct socket.

How was it tested?

Mariadb

Optionally, create a deliberately broken config option in the default mariadb.cnf as a canary:

echo -e "[server]\nunknown_param_to_break_mariadbd_devbox_testing=true" | sudo tee -a /etc/mysql/mariadb.cnf

Then run:

mkdir /tmp/mariadbtest
cd /tmp/mariadbtest
devbox init
devbox add mariadb
devbox run mariadbd --verbose --help | grep ^port   # prints 3306
echo "port = 13306" >> devbox.d/mariadb/my.cnf  # Set a nonstandard port
devbox run mariadbd --verbose --help | grep ^port   # prints 13306, showing my.cnf is used
devbox services up -b
devbox run mariadb -e "show variables where variable_name in ('datadir', 'port', 'log_error', 'socket');"
devbox run mariadb -e "status;"

For me the latter prints:

jturner@jturner-desktop:/tmp/mariadbtest$ devbox run mariadb -e "show variables where variable_name in ('datadir', 'port', 'log_error', 'socket');"
Info: Running script "mariadb" on /tmp/mariadbtest
+---------------+---------------------------------------------------------+
| Variable_name | Value                                                   |
+---------------+---------------------------------------------------------+
| datadir       | /tmp/mariadbtest/.devbox/virtenv/mariadb/data/          |
| log_error     | /tmp/mariadbtest/.devbox/virtenv/mariadb/run/mysql.log  |
| port          | 13306                                                   |
| socket        | /tmp/mariadbtest/.devbox/virtenv/mariadb/run/mysql.sock |
+---------------+---------------------------------------------------------+

jturner@jturner-desktop:/tmp/mariadbtest$ devbox run mariadb -e "status;"
Info: Running script "mariadb" on /tmp/mariadbtest
--------------
/tmp/mariadbtest/.devbox/nix/profile/default/bin/mariadb from 11.8.8-MariaDB, client 15.2 for Linux (x86_64) using readline 5.1

Connection id:          4
Current database:
Current user:           jturner@localhost
SSL:                    Cipher in use is TLS_AES_256_GCM_SHA384, cert is OK
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server:                 MariaDB
Server version:         11.8.8-MariaDB MariaDB Server
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /tmp/mariadbtest/.devbox/virtenv/mariadb/run/mysql.sock
Uptime:                 1 min 0 sec

Threads: 1  Questions: 9  Slow queries: 0  Opens: 17  Open tables: 10  Queries per second avg: 0.150
--------------

mysql80

mkdir /tmp/mysqltest
cd /tmp/mysqltest
devbox init
devbox add mysql80
devbox run mysqld --verbose --help | grep ^port    # prints 3306
echo "port = 23306" >> devbox.d/mysql80/my.cnf  # Set a nonstandard port
devbox run mysqld --verbose --help | grep ^port   # prints 23306, showing my.cnf is used
devbox services up -b
devbox run mysql -uroot -e "show variables where variable_name in ('datadir', 'port', 'log_error', 'socket');"
devbox run mysqladmin -uroot  create mydb     # Show mysqladmin wrapper works
devbox run mysql -uroot mydb -e "select database();"  # prints 'mydb'
devbox run mysqldump -uroot mydb    # prints sql

For me the latter commands show:

jturner@jturner-desktop:/tmp/mysqltest$ devbox run mysql -uroot -e "show variables where variable_name in ('datadir', 'port', 'log_error', 'so
cket');"
Info: Running script "mysql" on /tmp/mysqltest
+---------------+-------------------------------------------------------+
| Variable_name | Value                                                 |
+---------------+-------------------------------------------------------+
| datadir       | /tmp/mysqltest/.devbox/virtenv/mysql80/data/          |
| log_error     | /tmp/mysqltest/.devbox/virtenv/mysql80/run/mysql.log  |
| port          | 23306                                                 |
| socket        | /tmp/mysqltest/.devbox/virtenv/mysql80/run/mysql.sock |
+---------------+-------------------------------------------------------+

jturner@jturner-desktop:/tmp/mysqltest$ devbox run mysqladmin -uroot  create mydb              
Info: Running script "mysqladmin" on /tmp/mysqltest                    
jturner@jturner-desktop:/tmp/mysqltest$ devbox run mysql -uroot mydb -e "select database();"
Info: Running script "mysql" on /tmp/mysqltest
+------------+
| database() |
+------------+
| mydb       |
+------------+

This change (#2904) finishes the job begun by #2524. Also obsoletes (fixes in a nicer way) #2522.

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.

… isolation (jetify-com#2904)

By default, mariadbd reads /etc/mysql/mariadb.cnf, and if the system has
another version of MariaDB installed, those config files can cause the
Devbox mariadbd to fail (e.g. requesting loading plugins not available).

This commit causes devbox mariadbd (and mysqld) to only read from
$MYSQL_CONF (typically devbox.d/mariadb/my.cnf).

Additionally, wrap the client/admin binaries (mariadb, mariadb-admin,
mariadb-dump, mysqldump, mysql, mysqladmin) with --defaults-file and
--socket so they also ignore /etc/mysql and connect to the correct
socket.

Fixes jetify-com#2904
@jefft jefft force-pushed the jefft/mysql-plugin-ignore-etc-mysql branch from 50c5808 to e4e043f Compare July 7, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

mariadb reads and get confused by /etc/mysql/ config files

1 participant