Title: MySQL error using MC with remote database
Last modified: August 16, 2023

---

# MySQL error using MC with remote database

 *  Resolved [joergpe](https://wordpress.org/support/users/joergpe/)
 * (@joergpe)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/mysql-error-using-mc-with-remote-database/)
 * I am using one WP site ‘Calendar’ as normal MyCalendar host and a second site‘
   client’ as read-only view of the calendar, option “Get data (events, categories
   and locations) from a remote database” is enabled.
 * I add some demo events, with name and date and location, 
   Everything works as
   expected.
 * But when I add 42 or more events the View on Calendar is ok, but the Client site
   is broken with error establishing a databse connection.
 * ![](https://i0.wp.com/client.erlebedichselbst.de/wp-content/uploads/2023/08/Error-
   database.jpg?ssl=1)
 * When I delete one event everything is ok again.
 * When I delete the location in every event everything is ok again.
 * I turned on WP Debug and got a lot of error messages like this:
 * ![](https://i0.wp.com/client.erlebedichselbst.de/wp-content/uploads/2023/08/Error-
   2.jpg?ssl=1)
 * And this message at the end of the page:
 * ![](https://i0.wp.com/client.erlebedichselbst.de/wp-content/uploads/2023/08/Error-
   3.jpg?ssl=1)
 * ==My Calendar:==
   Version: 3.4.17DB Version: 3.4.17==WordPress:==Version: 6.3=
   =Extra info:==PHP Version: 7.4.33DB Version: 8.0.34
 * I really need the remote feature. Can you please look into this?
   Yours Jörg

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

 *  Plugin Author [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * (@joedolson)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/mysql-error-using-mc-with-remote-database/#post-16981011)
 * The warning about having more than `max_user_connections` is coming from the 
   MySQL set up, and isn’t something I can do anything about. This is most likely
   set by your host, and you’ll need to communicate with them about changing that.
   The MySQL instructions are here: [https://dev.mysql.com/doc/refman/8.0/en/user-resources.html](https://dev.mysql.com/doc/refman/8.0/en/user-resources.html),
   but those are unlikely to be something you can change yourself.
 *  Thread Starter [joergpe](https://wordpress.org/support/users/joergpe/)
 * (@joergpe)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/mysql-error-using-mc-with-remote-database/#post-16981075)
 * Please note: when I remove the location of the events, the warnings and the error“
   establishing a database connection is gone”.
   So I think the SQL statements that
   selects the location produces an error and the SQL connection is not closed correctly
   and is running out of connections.
 * I use a server wih 300 max_user_connections that should be enough.
 * And the error occures with 42 or more events in the list so if I have more max_user_connections
   I will run into the error later with e.g. 200 entries.
 * Please give this problem a look, the cool feature “remote DB” is not usable like
   this.
 *  Thread Starter [joergpe](https://wordpress.org/support/users/joergpe/)
 * (@joergpe)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/mysql-error-using-mc-with-remote-database/#post-17011828)
 * The max_connection error is in include/db.php line 135.
   Every request to the 
   remote database opens a new connection to the remote database. Here is a fix:
 * function mc_is_remote_db() { 
    global $wpdb;  **global $remotedb; ** $mcdb = 
   $wpdb;  if ( ‘true’ === mc_get_option( ‘remote’ ) && function_exists( ‘mc_remote_db’)){**
   if ( !isset( $remotedb ) ) {  $remotedb = mc_remote_db(); }  $mcdb = $remotedb;}
   return $mcdb;}
 * The Warning can be removed in my-calendar-locations.php line 203
   if ( ! $post_id**&&
   isset($mcdb->postmeta)** ) {
 * Would be nice if you can push this in next Version!
 *  Plugin Author [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * (@joedolson)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/mysql-error-using-mc-with-remote-database/#post-17017119)
 * Thanks! I saw you also opened a Github issue, so I’m going to close this; but
   it’ll make it into a near future release.

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

The topic ‘MySQL error using MC with remote database’ is closed to new replies.

 * ![](https://ps.w.org/my-calendar/assets/icon-256x256.png?rev=1097576)
 * [My Calendar - Accessible Event Manager](https://wordpress.org/plugins/my-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/my-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/my-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/my-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/my-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/my-calendar/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/mysql-error-using-mc-with-remote-database/#post-17017119)
 * Status: resolved