I'm on Debian 10 Buster.

I can't figure out what's wrong with this init.d script? Sometimes it doesn't run at server shutdown.

My MySQL error_log fills up with "Status information" when the server reboots due to SIGHUP. Here is a link describing this behavior: MySQL Server response to SIGHUP signals

This init.d script /etc/init.d/mysql I'm using was taken directly from the official MySQL release deb with a couple minor modifications by myself, which are documented in the file.

And here is the sourced mysql-helpers file referenced by the init.d script.

Stopping/starting/restarting MySQL at runtime never produces the SIGHUP, but sometimes the script chokes with no logging info. The .pid is gone, but MySQL silently fails to start.

The frustrating part is it sometimes runs at shutdown and sometimes not. It is random; 75% it doesn't run, 25% it does run.

Another part of this question could be, Does anyone know where to find a working init.d script for MySQL 5.7.37 on Debian 10?

1 Answer 1


why you dont try to use systemd to manage daemons, its easier and available since debian Jessie. /etc/systemd/system/servicemysql.service

Description=MySQL task
Before=poweroff.target halt.target shutdown.target

ExecReload=/usr/bin/kill -HUP $MAINPID


Dont forget to give 0644 permissions to this file and after every modification run:

systemctl daemon-reload

then to enable the daemon run:

systemctl enable <name of the service>

and to start it run:

systemctl start <name of the service>

For checking if the service is running execute:

systemctl status <name of the service>
  • Does systemd still require using the init.d script? Does using systemctl replace the service command? e.g. service mysql restart is the same as systemctl mysql restart? Getting desperate, so I may just try it.
    – Jeff
    Mar 15, 2022 at 9:37
  • Yes i forgot to tell you, the equivalence is systemctl <command> mysql.service in your case systemctl restart mysql.service see --help or man for more info but the script should be located in /etc/systemd/system not in init.d path so i recommend to delete the old service from there
    – ser356
    Mar 15, 2022 at 9:41
  • You're welcome. After all init.d facilities are not so "fáciles". Here's more useful info about some config vars and how to use if the daemon still not working. stackoverflow.com/questions/38072849/…. freedesktop.org/software/systemd/man/systemd.unit.html
    – ser356
    Mar 15, 2022 at 10:03
  • As I mencioned in my answer after every update/change in the config file if the service you should do systemctl daemon-reload then the systemd equivalent for update-rc.d is systemctl enable MySQL.service. I hope this helps you.
    – ser356
    Mar 15, 2022 at 12:34
  • 1
    Hi, /etc/init.d is a deprecated form of running services from SystemVInit that is included in some system services and still included in old daemons. Today, exclusively with Systemd is possible to manage and run your services only editing your script on /etc/systemd/system So you don't have to work on /etc/init.d only on /etc/systemd/system More info related in: askubuntu.com/questions/911525/…
    – ser356
    Mar 16, 2022 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .