How to Configure MySQL 8.0 as a Systemd Notify Service on Linux
This guide walks through verifying MySQL 8.0.16+, copying and editing the mysqld.service file, setting the Service Type to notify, adding NotifyAccess, adjusting ExecStart, reloading systemd, restarting MySQL, and checking its status, while covering SELinux, firewall, and notification‑delay optimizations.
Introduction
Systemd is the modern init system for most Linux distributions, providing process management, automatic service start, and dependency handling. MySQL 8.0.16 and later can integrate natively with systemd using the notify service type, which improves status reporting and reliability.
Step 1: Verify MySQL Version
Ensure the installed MySQL version is 8.0.16 or newer, as only these versions support the notify type.
mysql --versionStep 2: Copy and Edit the Service File
To avoid modifying the original system file, copy the default MySQL service unit to /etc/systemd/system/ and edit it with a text editor.
sudo cp /usr/lib/systemd/system/mysqld.service /etc/systemd/system/ sudo vim /etc/systemd/system/mysqld.serviceStep 3: Modify the Service Type to notify
In the [Service] section, make the following changes:
Set Type to notify to enable systemd notifications.
[Service]
Type=notifyAdd NotifyAccess=all to allow MySQL to send status updates to systemd. NotifyAccess=all Ensure ExecStart points to the MySQL executable mysqld . ExecStart=/usr/sbin/mysqld Make sure the path is correct and remove any reference to mysqld_safe, which does not support systemd notifications.
Step 4: Reload Systemd Configuration
After saving the modified unit file, reload the systemd manager to apply the changes.
sudo systemctl daemon-reloadStep 5: Start or Restart MySQL Service
Restart the MySQL service so that it runs with the new systemd configuration. sudo systemctl restart mysqld The service should now send notifications using the notify mechanism.
Step 6: Verify MySQL Service Status
Check the service status to confirm it is active and using the notify type. sudo systemctl status mysqld The output should show active (running), indicating a successful start.
Additional Considerations
SELinux Settings : If SELinux is enforcing, adjust policies (e.g., with audit2allow ) to permit mysqld to send notifications.
Firewall Settings : Ensure the firewall does not block MySQL’s port (default 3306). Use firewall-cmd to allow the required ports.
Optimizing Notification Latency : Fine‑tune MySQL configuration parameters to reduce startup time and improve reliability of the notify mechanism.
Conclusion
Integrating MySQL 8.0 with systemd’s notify mechanism provides finer‑grained service management and monitoring, enhancing system stability and enabling faster fault detection and recovery.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ops Development & AI Practice
DevSecOps engineer sharing experiences and insights on AI, Web3, and Claude code development. Aims to help solve technical challenges, improve development efficiency, and grow through community interaction. Feel free to comment and discuss.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
