Centos – Auto-start MariaDB using systemd after it has crashed

centoscentos7mariadbMySQL

I am trying to set up MariaDB in a way that it automatically recovers — basically restarts, from a crash.

Based on this article — scroll down to Auto-starting Services with systemd, I opened /etc/systemd/system/multi-user.target.wants/mariadb.service file but there were nothing like this as the article explains:

[Service]
...
...
Restart=always
...

So I added the [Service] section and the Restart=always underneath, restarted the service and killed the process to see if it will start automatically, but it didn't.

I was wondering if I'm editing the wrong file or if there are other ways of achieving the same thing. Server is a remote machine running CentOS 7.

Best Answer

After making changes to systemd units, you need to run systemctl daemon-reload for those changes to have effect.