Title: two db, one wordpress
Last modified: November 6, 2016

---

# two db, one wordpress

 *  [waylayer](https://wordpress.org/support/users/waylayer/)
 * (@waylayer)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/)
 * Hello,
    i was thinking about the issues on my shared hosting, one issue is the
   bd connection because this connection is constantly down, and this cause me problems.
 * i have a vps, and i have mysql installed there, i want know if is possible use
   my mysql (vps) when the main mysql (shared hosting) is down.
 * mysql (vps) is a mirror of main mysql (shared hosting)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/#post-8401508)
 * It’s unlikely that the database server on your shared hosting site is set to 
   support database replication.
 *  Thread Starter [waylayer](https://wordpress.org/support/users/waylayer/)
 * (@waylayer)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/#post-8401532)
 * that colud be true, i don’t know that.
 * ok, then if i use the main database (shared hosting) but the database (vps) is
   only a backup (1 week age maybe)? it’s posible do what i explain? change to the
   database (vps) if database (sahred hosting) is down?
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/#post-8401580)
 * what you want to do probably is not possible through shared hosting. If your 
   site can’t be down, you should look into high-availability hosting. It’s not 
   cheap. Or you can look for a more reliable host.
 *  Thread Starter [waylayer](https://wordpress.org/support/users/waylayer/)
 * (@waylayer)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/#post-8401632)
 * really? i can’t connect me to a external database? i need try a little. but… 
   if this is possible, wordpress can do that?
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/#post-8401787)
 * Yes, you can do that, but dynamically switching won’t work if your shared host
   is down.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/#post-8403011)
 * You **may** have half a chance of dynamically switching to an alternate DB if
   your primary one is down. It depends if the failure occurs upon reconnecting 
   or initial connect. If reconnecting, like Steve says — it won’t work.
 * If the initial connection fails, you can create a custom DB error handling file
   called db-error.php that is placed in /wp-content/. [Relevant Code](https://core.trac.wordpress.org/browser/tags/4.6/src/wp-includes/wp-db.php#L1558).
 * Complete speculation now. A solution appears plausible, but I couldn’t say it
   would actually work. This error handler could instantiate another `wpdb` class
   object, connecting to the alternate DB. You eventually would then assign that
   object to the global `$wpdb` variable. I don’t know if you can do so within the
   error handler, the swap may need to be deferred until the original object instantiation
   is complete. The error handler would need to return `true` to avoid killing the
   thread, which could cause the object to be unstable since there is no valid connection.
   Thus I’m not sure this would even work, but it might be worth a try.
 *  Thread Starter [waylayer](https://wordpress.org/support/users/waylayer/)
 * (@waylayer)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/#post-8404335)
 * [@sterndata](https://wordpress.org/support/users/sterndata/): no, no, my shard
   hosting only have down the data base mysql, not the apache.
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/): i will try. thank you

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘two db, one wordpress’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [waylayer](https://wordpress.org/support/users/waylayer/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/two-db-one-wordpress/#post-8404335)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
