Load Balancing Second Wordpress Website Using Same Database

I have had a second Wordpress website for about a year and the way I sync them is to download the database and upload it to the second site, but there has to be a way that the second site using the same database from the first site in Wordpress. Both sites are on different servers. I have something in wp-config.php wrong because one of the errors that I see is the user of the second database is [email protected] instead of [email protected].

I have researched this for about a day and can’t find any relevant information. The servers are set up for remote MySQL correctly.

I can’t see how Cloudflare has any influence over database permissions. If it’s a connectivity issue (which it doesn’t sound like), it’s best to use server IP address for a direct connection, the firewall off any other IP addresses for DB ports.

1 Like

I agree with you and thank you for the reply, but do you know what an example wp-config.php would look like for a second WP website using the same database?

If someone created an app that would do this and added it to the Cloudflare app store, it would open the door for load balancing to thousands of WP admin. I would buy it in a New York minute.

As far as I understand, you mean on WordPress multisite?

You can attach, or not?, multiple websites and/or domains to the same load balancer, if all of them are on the same server/IP address.

You want to manage or “load balance” multiple WordPress installations with one Cloudflare load balancer?

Yes, that is correct. I already use load balancing, and the websites are on different servers. I just want to use the same database for both so I don’t have to download the database and upload it to the second sever every time.

You would need to have opened ports at your origin (3306 if default) and allow IP address for each user (or more of them) from each “wordpress install domains” to connect to other one, also knowing the “master” or at least “the one” where the database is hosted, so using the same username and password for MySQL you can connect.

Instad of DB_HOST with the value of localhost you would write either your hostname or use direct an IP address to connect to your “the one” (where the database is) from others.
That way, separate WordPress installs would use the database on “the one” using correct credentials.

The thing can be more complex if using secure mysql, so therefore you would need to setup an SSL for your MySQL and use it thatway.

Later on, you can setup WordPress multisite and for easier manage of all of them either like that or using ManageWP.com.

This topic on WordPress support can help you:

Furthermore, hope you do not have a cluster, where you run “one master” MySQL and two or more “child” MySQL instances, each of them on a separate server and different IP address. That would be a really complex system at a first sight to manage at least.

1 Like

Thank you for the response, and I have already read both of those threads thoroughly, and made the adjustments to wp-config.php and it still does not work. I am receiving an “access denied” for the remote user [email protected].

If being behind Cloudflare, said proxied via :orange:, maybe you … should use IP address and not a hostname/domain for DB_HOST?

Because … if not on paid plan, you cannot use some ports either to connect than the compatible and allowed ones as stated below?

Neither [email protected]_address rather than hostname/domain.
Have you added your MySQL user with the allowed IP address to make connection and is your port (assuming 3306) open for remote connection?

But then goes the question around, what about load balancing the connections over Cloudflare, right?

Thank you for the ideas, and I am already using CF for load balancing and it works perfect. I have already tried what you suggested in wp-config and the error then shows [email protected]@secondserverhostname. To use the ip on the second server, something needs to be reconfigured with the second site wp-config (I think).

If someone created an app for the Clouflare app store called “Cloudflare LB Helper” and you entered the DB credentials of the main site and then the credentials of the second site, and it would sync those 2 sites, that would be perfect.