简体   繁体   English

如何在C ++中的mysql_init期间解决mysql错误“内存不足”?

[英]How to resolve the mysql error “insufficient memory” during mysql_init in c++?

I have a problem with a new deployement of a server program "MyServer" on Ubuntu 12.04 . 我在Ubuntu 12.04上新部署服务器程序“ MyServer”时遇到问题。 This program works fine on the 1st machine . 该程序在第一台机器上运行良好

But on the new machine, the program MyServer return an exception during mysql_init() : " Insufficient memory: can not create handler for mysql_init() " 但是在新机器上,MyServer程序在mysql_init()期间返回异常:“ 内存不足:无法为mysql_init()创建处理程序

However these 2 machines have both 2Go RAM and MySQL seems to be well-installed (we can run request from mysql client) and have the same my.cnf . 但是,这两台机器都具有2Go RAM,并且MySQL似乎安装得很好(我们可以从mysql客户端运行请求),并且具有相同的my.cnf

This error appears during these lines : 这些行中出现此错误:

sql::Driver * driver = get_driver_instance();

if(driver)
{
    // Lets try to connect.
    std::stringstream completeHost;
    completeHost << "tcp://"
                << (configuration->getSocket()->getHost())
                << ":"
                << (configuration->getSocket()->getPort());

    ////// **It throws this exception below** : //////
    sql::Connection * connection = driver->connect(completeHost.str(),
                                                   configuration->getUser(),
                                                   configuration->getPassword());
}

And the connection parameters are correct, since this is the same used with mysql client. 并且连接参数正确,因为这与mysql客户端使用的相同。

What's wrong ? 怎么了 ? Thanks a lot ! 非常感谢 !

I just came across the same problem and I may have found a workaround. 我刚遇到相同的问题,可能已经找到解决方法。 We also had two machines, one with our software working and the other one throwing the same message Insufficient memory: can not create handler for mysql_init() . 我们也有两台机器,一台运行我们的软件,另一台抛出相同的消息Insufficient memory: can not create handler for mysql_init()

After a while, we noticed that the second machine went through some package updates. 一段时间后,我们注意到第二台计算机进行了一些软件包更新。 libmysqlclient18 was one of these packages. libmysqlclient18是这些软件包之一。

Once i downgraded my libmysqlclient18 from 5.5.38 to 5.5.22 (the same version that the working one) it started working again ! 一旦我将我的libmysqlclient18从5.5.38降级到5.5.22(与工作版本相同的版本),它就又开始工作了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM