The following script is used to start mysql automatically when it is failed or stopped on the server. You can set 2…