Repository navigation
feat(services): read MySQL and MariaDB settings from my.cnf in the data directory - #105
Merged
Merged
Conversation
…ta directory Start the server with --defaults-file=<data dir>/my.cnf instead of --no-defaults. Flock creates the file the first time it starts the server and never overwrites it, so a setting a project needs to match production (sql_mode, max_allowed_packet, ngram_token_size, ...) survives restarts and updates. Other my.cnf files on the machine are still ignored, Flock's own flags still win over the file, and MySQL now loads SET PERSIST values from mysqld-auto.cnf. Fixes flock-php#88 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Persisted MySQL port settings can override Flock’s configured endpoint on restart, while the shared documentation example contains an unsupported variable that causes MariaDB startup to fail.
2 open issues
What changed in this PR
Adds per-data-directory MySQL and MariaDB configuration, addressing #88 so local services can use application-specific server settings.
Changes:
- Starts servers with
--defaults-fileand creates a template after initialization without overwriting existing edits. - Adds a regression test for argument ordering, file creation timing, and preservation of edits.
- Documents configuration locations, example settings, and restart behavior.
| File | Description |
|---|---|
internal/catalog/kinds.go |
Creates my.cnf when absent and uses it for server startup. |
internal/catalog/catalog_test.go |
Tests option-file creation, startup arguments, and preservation. |
docs/services.md |
Explains custom MySQL and MariaDB settings. |
Review effort: Balanced
onairmarc
requested changes
Nov 4, 2026
onairmarc
left a comment
Member
There was a problem hiding this comment.
please address copilot findings
…cs example MySQL loads mysqld-auto.cnf after the command line, so a port, bind address, socket or directory written into it by hand would win over Flock's flags on the next start. MySQL itself refuses to SET PERSIST these, so only a hand edit can do it: Flock now doesn't start the server then, and names the file and the setting to remove. Other persisted settings keep working. The docs' example used ngram_token_size, which MariaDB doesn't know and won't start with. The shared example now uses settings both servers have, and the n-gram one is marked MySQL only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
onairmarc
approved these changes
Nov 4, 2026
onairmarc
enabled auto-merge
November 4, 2026 19:02
Member
|
Hi @sloan58 thanks for this PR! Merging it |
lukas-frey
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes #88
What
MySQL and MariaDB now start with
--defaults-file=<data dir>/my.cnfinstead of--no-defaults.my.cnfin the line's data directory (e.g.services/mysql/data/8.4/my.cnf) the first time it starts the server. It holds a commented[mysqld]template and is never overwritten, so edits survive restarts,flock services updateand switching versions. Each version has its own data directory, so each has its own file, likepostgresql.conf.mysqld --initializerefuses a data directory that isn't empty. Existing installs get the file on their next start. With only comments in it, they behave exactly as before.--defaults-filereads only that file, so Homebrew's/opt/homebrew/etc/my.cnf,/etc/my.cnfand~/.my.cnfare still ignored.--basedir,--datadir,--bind-address,--port,--socket,--mysqlx=OFF) come after it and win over the file.SET PERSISTvalues frommysqld-auto.cnf, as documented.--no-defaultsskipped that file too.--no-defaultsused during initialisation and by thecreate-dbclient is unchanged.docs/services.md.Testing
TestSQLSpecReadsTheDataDirectorysOptionFile:--defaults-fileis the first argument,--no-defaultsis gone, the file is created after initialising, and an edited file isn't overwritten on the next start.gofmt,go vetandgo test -race(excludingtools/, as in CI) pass on macOS.Kind.Spec. Each run:my.cnfwas written;ngram_token_size = 3(MySQL) orinnodb_ft_min_token_size = 2(MariaDB), plusmax_allowed_packet = 256Mandport = 1234;@@portis still Flock's port (the flag wins over the file's 1234), and the file wasn't overwritten;SET PERSIST sql_mode = ..., restarts again and checks it's still applied.On Windows the run also used
mysqladmin/mariadb-adminshutdown, and left no server running on any platform.MariaDB 12.3.3 on Windows doesn't start with these arguments, and doesn't start with the current
--no-defaultsones either, on a freshly initialised data directory. SSL setup fails:caching_sha2_password: failed to read private_key.pemthenSSL error: Unable to get private key/Failed to setup SSL/Aborting. So it isn't caused by this change, and I'll open a separate issue for it. This change does give a workaround: withskip-sslinmy.cnf, it starts, answers queries (have_ssl = DISABLED) and shuts down cleanly. I've only seen it on Windows on ARM, so I can't say whether native x64 Windows is affected.Also on Windows:
mariadb-install-db.exewrites its ownmy.iniinto the data directory.--defaults-filepoints atmy.cnf, so thatmy.inistays ignored, as it was under--no-defaults.🤖 Generated with Claude Code