在远程主机上查询期间与 MySQL 服务器的连接丢失 [英] Lost connection to MySQL server during query on remote host

查看:60
本文介绍了在远程主机上查询期间与 MySQL 服务器的连接丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 cppdb 和 mysql 的 cppcms 框架,并在尝试对远程数据库进行查询时出现查询期间与 MySQL 服务器的连接丢失"错误.

I'm working with cppcms framework with cppdb and mysql and got "Lost connection to MySQL server during query" error when trying to make a query on a remote database.

我在本地也有相同的数据库,该应用程序可以与那个数据库配合使用.

I also have the same database locally, and the app works ok with that one.

远程mysql版本:mysqld Ver 5.5.29-0ubuntu0.12.10.1 for debian-linux-gnu on i686 ((Ubuntu))

Remote mysql version: mysqld Ver 5.5.29-0ubuntu0.12.10.1 for debian-linux-gnu on i686 ((Ubuntu))

感谢您的帮助

推荐答案

两个问题:

  • 您使用连接池吗?
  • 您是在使用完 cppdb::session 对象后销毁它还是一直保持活动状态?
  • Do you use connection pooling?
  • Do you destroy cppdb::session object when you done using it or you are keeping it active all the time?

如果你一直保持 cppdb::session 你可能不需要这样做,因为 MySQL 在一段时间后关闭空闲连接.最好使用 CppDB 提供的连接池.

If you keep cppdb::session all the time you probably not need to do it because MySQL closes idle connections after certain time period. It is better to use connection pooling provided by CppDB.

如果您已经在使用连接池,请尝试将 @pool_max_idle 参数更改为较小的值.

If you are already using connection pooling try to change the @pool_max_idle parameter to smaller value.

参见:http://cppcms.com/sql/cppdb/connstr.html#speckeys 了解更多详情

这篇关于在远程主机上查询期间与 MySQL 服务器的连接丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆