• 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)

    (@sterndata)

    Volunteer Forum Moderator

    It’s unlikely that the database server on your shared hosting site is set to support database replication.

    Thread Starter waylayer

    (@waylayer)

    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)

    (@sterndata)

    Volunteer Forum Moderator

    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

    (@waylayer)

    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)

    (@sterndata)

    Volunteer Forum Moderator

    Yes, you can do that, but dynamically switching won’t work if your shared host is down.

    Moderator bcworkz

    (@bcworkz)

    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.

    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

    (@waylayer)

    @sterndata: no, no, my shard hosting only have down the data base mysql, not the apache.

    @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.