How to prevent: "Error establishing a database connection"?

Hi:

Recently I had “Error establishing a database connection” on a live site witch was shut down for one day. I lost rankings & traffic.

How should I prevent this from ever happening again?

Is it due to mysql down? if yes, then You should optimize it and might be great to have daemon for mysql.

Hi WebH:

Thanks for answering.

Yes, it is due mysql is down. (No database connection - Error)

What “daemon for mysql” means, and how to do it? Do you have a url for a guide to do that?

Also can you give a way to establish the database connection once it is down for EE.V4? (Now I always create a new droplet and run a new EE & Wordpress installation over again. I do it for a live site. This time consuming. And also people coming in to the site see errors untill I finish all the installations).