Convert MariaDB Settings with mariadb-service-convert
Moving MariaDB from old mysqld_safe settings to systemd gets a lot less scary once mariadb-service-convert does the translation for you. You will generate a systemd drop-in from the settings currently visible to the tool, review the result, install it without touching the packaged unit, and verify the service. Allow about fifteen minutes, plus a restart window if MariaDB is already serving applications.
The route
Jump straight to the step you need, or tick off Done means at the end.
The examples use MariaDB 10.11.14 from the installed mariadb-server package. The command's manual page is dated 15 May 2020, so the generated text and the installed unit on your own host are the real authority for this run. You need shell access and, for installation, an account allowed to use sudo.
1. Check the installed command
First confirm which binary and package version you are about to use. These are ordinary read-only commands:
$ command -v mariadb-service-convert
/usr/bin/mariadb-service-convert
$ mariadb --version
mariadb Ver 15.1 Distrib 10.11.14-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
$ dpkg-query -W -f='${Package} ${Version}\n' mariadb-server
mariadb-server 1:10.11.14-0ubuntu0.24.04.1
Checkpoint
If the command is missing, stop and install or repair the package through your normal package-management process. Do not copy a generated file from another host; its MariaDB configuration may not match yours.
2. Generate a temporary file
The utility takes no documented options. It writes a service configuration to standard output, so redirect that to a temporary file first rather than writing straight into /etc:
$ work_dir=$(mktemp -d /tmp/mariadb-service-convert.XXXXXX)
$ mariadb-service-convert > "$work_dir/migrated-from-my.cnf-settings.conf"
$ printf 'exit status: %s\n' "$?"
exit status: 0
$ sed -n '1,120p' "$work_dir/migrated-from-my.cnf-settings.conf"
# converted using /usr/bin/mariadb-service-convert
#
[Service]
StandardOutput=syslog
StandardError=syslog
SyslogFacility=daemon
SyslogLevel=err
SyslogIdentifier=mysqld
Your own output can list different settings. The important shape is a systemd [Service] section preceded by a conversion comment. A successful exit status means the generator ran; it does not mean every setting belongs in production.
3. Review the generated settings
Read the whole temporary file before installing anything. Compare each setting against the current MariaDB service and against the reason you are migrating off mysqld_safe settings in the first place:
$ sed -n '1,240p' "$work_dir/migrated-from-my.cnf-settings.conf"
$ systemctl cat mariadb.service
$ systemctl show mariadb.service --property=DropInPaths --no-pager
The generated file is a drop-in, not a full replacement for mariadb.service. In particular, do not assume it carries ExecStart, user and group settings, limits, or hardening from the packaged unit. Leave the package's unit file untouched so upgrades can still replace it safely.
Safety warning
A drop-in can change logging, resource limits, startup behaviour or other service properties. If the output contains a setting you cannot explain, do not install it. Save the temporary file for investigation, or discard it and fix the source configuration first.
4. Install the reviewed drop-in
Only this step changes system state, and it needs elevated privileges. The manual recommends a path under /etc/systemd/system/mariadb.service.d/. Create the directory and copy the reviewed file with a fixed mode:
$ sudo install -d -m 0755 /etc/systemd/system/mariadb.service.d
$ sudo install -o root -g root -m 0644 \
"$work_dir/migrated-from-my.cnf-settings.conf" \
/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
Check what actually got installed before asking systemd to reread unit files:
$ sudo sed -n '1,240p' /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
$ systemctl show mariadb.service --property=DropInPaths --no-pager
DropInPaths=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
If the destination already exists, install replaces it. Preserve the old version first if you might want a quick rollback:
$ sudo cp --preserve=all \
/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf \
/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf.bak
5. Reload and validate without restarting
Ask systemd to reread unit files, then inspect the merged result. This step does not restart MariaDB:
$ sudo systemctl daemon-reload
$ systemctl cat mariadb.service
$ systemd-analyze verify mariadb.service
Checkpoint
systemd-analyze verify should print nothing for a valid unit. If it reports an error, do not restart the service; fix the source or remove the drop-in, then reload systemd again.
6. Apply the change during a maintenance window
A reload only updates systemd's view of the configuration. To make a service property take effect for a running MariaDB process, schedule a restart and check the result:
$ sudo systemctl restart mariadb.service
$ systemctl is-active mariadb.service
active
$ systemctl status mariadb.service --no-pager
Warning
Restarting a database interrupts clients. Check application impact and replication status before doing it, and keep the current shell open so you can read failures immediately. If the service does not settle back to active, check systemctl status mariadb.service and journalctl -u mariadb.service -b --no-pager.
7. Undo the drop-in if needed
To return to the packaged unit, remove only the file created for this migration, then reload systemd. Removing a drop-in changes state and needs sudo:
$ sudo rm /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
$ sudo systemctl daemon-reload
$ systemctl show mariadb.service --property=DropInPaths --no-pager
Recovery
If you made a backup, restore it with sudo install -o root -g root -m 0644 ... rather than guessing at its contents. Restart MariaDB only after checking the merged unit again. Do not remove the whole drop-in directory if it holds files for other changes too.
Done means
- Checked the installed command: the binary and MariaDB package version match what you expect.
- Reviewed before installing: the generator's output was captured under
/tmpand read in full first. - Left the packaged unit alone:
mariadb.serviceitself was never edited. - Verified the drop-in: it appears in
DropInPathsandsystemd-analyze verifyreports no error. - Planned any restart: it was scheduled, checked, and followed by an
activeservice status.