Convert MariaDB Settings into a Reviewed systemd Drop-in
You will generate a systemd drop-in from the MariaDB settings currently visible to mariadb-service-convert, review the result, install it without editing 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 host are the 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 be different.
2. Generate a temporary file
The utility takes no documented options. It writes a service configuration to standard output. Redirect that output to a temporary file first, rather than writing directly 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 output can contain different settings. The important shape is a systemd [Service] section preceded by a conversion comment. A successful exit status means the generator completed; it does not mean that every setting is suitable for production.
3. Review the generated settings
Read the whole temporary file before installing it. Compare each setting with the current MariaDB service and with the reason you are migrating from mysqld_safe settings:
$ 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 complete replacement for mariadb.service. In particular, do not assume it contains ExecStart, user and group settings, limits, or hardening from the packaged unit. Keep the package's unit file untouched so upgrades can 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 correct the source configuration first.
4. Install the reviewed drop-in
Only this step changes system state and it requires 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 was 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 when you need 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 does not restart MariaDB:
$ sudo systemctl daemon-reload
$ systemctl cat mariadb.service
$ systemd-analyze verify mariadb.service
systemd-analyze verify should produce no output for a valid unit. If it reports an error, do not restart the service. Correct the source or remove the drop-in, then reload systemd again.
6. Apply the change during a maintenance window
A reload only changes 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
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 return to active, inspect 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 is a state change and requires 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
If you made a backup, restore it with sudo install -o root -g root -m 0644 ... instead of guessing at its contents. Restart MariaDB only after checking the merged unit again. Do not remove the entire drop-in directory if it contains files maintained for other changes.
Done means
- The installed command and MariaDB package version were checked.
- The generator's output was captured in
/tmpand reviewed before installation. - The packaged
mariadb.servicefile was not edited. - The drop-in appears in
DropInPathsandsystemd-analyze verifyreports no error. - Any restart was planned, checked, and followed by an
activeservice status.