Auto Restart MySQL if Crashed

This bash script is used to auto-restart MySQL or MariaDB database if it crashes or stops for any reason.

Create file


In the code, replace YOUR_ROOT_PW_HERE with your actual root password. If you are not using “root”, replace root with whatever username you use.

Make it executable

Create cronjob to run the script every 5 minutes.



Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *