You are asking for fail over, not load balancing, methinks.
Fail over is extremely difficult to do well, especially with equipment which is not within the same infrastructure. Best case would be to get a redundant geographic load balancer at your ISP which tests your sites and handles failover seamlessly. Since my guess is that's out of your budget, let's go for the sticks and chewing-gum method.
Since your issue apparently is MySQL, not the web server, then let's solve the problem at hand.
- Host A: Web server and MySQL database
- Host B: Web server and redundant MySQL database
The method I would use would be:
Store your database connection credentials on disk somewhere (obviously not within the web root) and load them upon each page connection. You can edit sites/default/settings.php like so:
$db_url = file_get_contents('/some/private/dir/drupal-db.url');
Write a background daemon which connects to the database every 5 seconds (or so), and logs failures in a machine-readable way on disk. After the connection fails after 30 seconds (or so), then "swap" the credentials stored on disk with those of the backup server. This will cause your web server to serve content from the alternate database server. If it comes back, reverse the process. Logging is essential in this case for debugging, etc.
If you want to get fancy, you can try to log all INSERT and UPDATE to disk on the web server, so you can potentially re-sync the databases after a failover. If it's mostly "read-only" then this may not be necessary.
The primary point here is to decouple fail over from the operation of the web app. It's more modular, and simplifies changes to the web app.
Finally, make sure that you can connect to your backup database from the primary server. You can do this on the command line, and using grant commands:
On Host B:
mysql> GRANT ALL PRIVILEGES ON drupaldb.* TO username@'126.96.36.199' IDENTIFIED BY 'mypassword';
Where the IP is of Host A.
And don't forget to flush!
mysql> FLUSH PRIVILEGES:
bash> mysql -u username -pmypassword -h hostb drupaldb