Restart a service automatically after pid is killed or crashed

move /usr/lib/systemd/system/mariadb.service to /etc/systemd/system/mariadb.service

Then under the [Service] section in the file add the following 2 lines:

Restart=always
RestartSec=3

Then run:
systemctl daemon-reload
systemctl restart mariadb

To test:
pgrep mysql
pkill mysql
pgrep mysql