Connector/C 使用
说完了mysql的基础,后面我们只关心使用,要使用C语言连接mysql,需要使用mysql官网提供的库,前往官网下载即可。...(myfd, "utf8");
第一个参数 MYSQL是 C api中一个非常重要的变量(mysql_init的返回值),里面内存非常丰富,有port,dbname,charset等连接基本参数。...;
return 1;
}
if(mysql_real_connect(my,host.c_str(),user.c_str(),passwd.c_str(),db.c_str...;
return 1;
}
if(mysql_real_connect(my,host.c_str(),user.c_str(),passwd.c_str(),db.c_str...进行测试连接:连接成功
这就连接成功了。