Repository navigation
Description
What
A way to start MySQL (and MariaDB) with custom server settings, the way Postgres already reads postgresql.conf from its data directory.
Why
My app's production database (RDS MySQL 8.4) runs with two non-default settings that its search depends on:
ngram_token_size = 3
innodb_ft_enable_stopword = 0
ngram_token_size is read-only: it can only be set when the server starts. A migration in the app refuses to build its FULLTEXT indexes on a server where it isn't 3, so I can't use Flock's MySQL for local development.
sqlSpec in internal/catalog/kinds.go starts the server with --no-defaults, which turns off every way of configuring it:
- option files (
my.cnf,--defaults-extra-file) are not read SET PERSIST/SET PERSIST_ONLYvalues, saved inmysqld-auto.cnfin the data directory, are not loaded either
To reproduce on Flock 1.0.0 with MySQL 8.4.13:
SET PERSIST_ONLY ngram_token_size = 3;
SET PERSIST innodb_ft_enable_stopword = 0;
-- flock restart
SELECT @@ngram_token_size, @@innodb_ft_enable_stopword; -- 2, 1
SELECT variable_name, variable_source FROM performance_schema.variables_info
WHERE variable_name IN ('ngram_token_size', 'innodb_ft_enable_stopword'); -- both COMPILEDmysqld-auto.cnf holds the values and the server did restart, but they aren't applied. The same applies to any setting an app needs to match production: sql_mode, max_allowed_packet, innodb_buffer_pool_size, lower_case_table_names, and so on.
Possible approach
Replace --no-defaults with --defaults-file=<data dir>/my.cnf:
- Flock creates the file the first time it starts the server (a
[mysqld]section with a commented hint) and never overwrites it afterwards. --defaults-filestill ignores/etc/my.cnf, Homebrew's/opt/homebrew/etc/my.cnfand~/.my.cnf, which I assume is why--no-defaultsis there.- It also lets MySQL load
mysqld-auto.cnf, soSET PERSISTworks as documented. - Flock's own flags (
--basedir,--datadir,--bind-address,--port,--socket) stay on the command line and take priority over the file, so a user's settings can't break Flock. - Each version has its own data directory, so each version gets its own file, like
postgresql.confdoes today. - MariaDB uses the same
sqlSpec, so it gets this too. --defaults-filehas to be the first argument, and the file must exist before the server starts.
Then flock restart applies any edits to the file.
Happy to send a PR if this fits the project.
Activity
onairmarc commentedon Nov 3, 2026
Hey @sloan58! Just assigned the issue to you! Workflows will now allow you to open a PR. Thanks for submitting this!
sloan58 commentedon Nov 4, 2026
Thanks, @onairmarc! PR 105 was just submitted. Let me know if you need any further changes.
feat(services): read MySQL and MariaDB settings from my.cnf in the da…