MySQL服务器消失了
这里是我的代码片段:
query.next();
qDebug()<<query.lastError();
qlonglong res=query.value(0).toLongLong();
qDebug()<<query.lastError();
以及相应的日志:
Debug: QSqlError(2006, "QMYSQL: Unable to execute query", "MySQL server has gone away")
Warning: QSqlQuery::value: not positioned on a valid record
Debug: QSqlError(2006, "QMYSQL: Unable to execute query", "MySQL server has gone away")
通常我的程序工作得很好(它在服务器上工作并接受来自客户端的连接),但是每天早上当我尝试连接它时,我都会收到上面的消息。
MySQL 服务器可能出现什么问题?
Here my code snippet:
query.next();
qDebug()<<query.lastError();
qlonglong res=query.value(0).toLongLong();
qDebug()<<query.lastError();
and the corresponding log I have:
Debug: QSqlError(2006, "QMYSQL: Unable to execute query", "MySQL server has gone away")
Warning: QSqlQuery::value: not positioned on a valid record
Debug: QSqlError(2006, "QMYSQL: Unable to execute query", "MySQL server has gone away")
Normally my program works just fine (it works on a server and accepts connections from clients), but every morning when I tried to connect it, I'm getting messages above.
What can be the problem with MySQL server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这已经很旧了,但碰巧是谷歌第一次点击“MySQL 服务器已经消失 QMYSQL:无法执行查询”。
即使我们不再有连接,QSqlDatabase::isOpen() 似乎仍然会返回 true。这是我捕获它的方法:
我能够通过使用“/etc/init.d/mysql restart”重新启动服务器来模拟这种情况,并继续向其发送查询,它最终会抛出此错误。我觉得这不应该在服务器端更改,事实上 8 小时对于保持空闲连接打开来说似乎非常长。
I know this is old but happens to be the first google hit for "MySQL server has gone away QMYSQL: Unable to execute query".
It seems QSqlDatabase::isOpen() will still return true even though we don't have a connection anymore. Here is how I catch it:
I was able to mimic this situation by restarting the server with "/etc/init.d/mysql restart" and keep sending queries to it and it eventually throws this error. I feel this shouldn't be changed server side, in fact 8 hours seems extremely long to keep an idle connection open.
来自 MySQL 手册:
有关此错误的更多详细信息,请参阅本手册页 。
From the MySQL Manual:
See this manual page for more details on this error.