linux 下使用c操作mysql数据库时写个测试程序 int main(void){ MYSQL m_mysql; mysql_init(m_mysql); const char pLocalhost[] = "localhost"; const char pUser[] = "root"; const char pPass[] = "123456"; const char pDB[] = "HTTPCONTROL"; if(mysql_re
linux 下使用c操作mysql数据库时写个测试程序
int main(void) { MYSQL m_mysql; mysql_init(&m_mysql); const char pLocalhost[] = "localhost"; const char pUser[] = "root"; const char pPass[] = "123456"; const char pDB[] = "HTTPCONTROL"; if(mysql_real_connect(&m_mysql,pLocalhost,pUser,pPass,pDB,0,NULL,0) == NULL) cout
编译后使用valgrind检测内存泄露
还是网上找最后找到了
http://dev.mysql.com/doc/refman/5.0/en/mysql-library-end.html
简单的说是在断开数据库连接后使用
mysql_library_end()
关闭MYSQL 使用的库
即在mysql_close(。。。)
后添加
mysql_library_end();
就ok了
再添加一句,在使用mysql API之前最好是
调用mysql_library_init(。。。。)