mysql_init(&mysql);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name");
if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
{
fprintf(stderr, "Failed to connect to database: Error: %s\n",
mysql_error(&mysql));
}试试看加上mysql_options()
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name");
if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
{
fprintf(stderr, "Failed to connect to database: Error: %s\n",
mysql_error(&mysql));
}试试看加上mysql_options()
解决方案 »
- mysql问题
- GUN Taso Debian Linux下安装MySql 5.0.67失败
- C# 链接mySQl数据库 增加数据的问题。
- 客户端library与header不匹配
- SQL更新语句求解 如果要更新的值为负数,如何将要更新的值变成0
- ODBC中用sql语言向mysql数据库添加数据的时候不能添加汉字
- 字段中保存着一个计算公式(g1 * 5 + g2 )是字符型的,我想对其中的字符g1、g2赋值后进行计算,得到数值,我该如何写sql
- mysql如何打开3306端口?
- MYSQL的数据能不能转化成ACCESS啊?
- 请问有没有带用户认证的PHPMyAdmin?
- 这条语句怎会也有语法错误呢?请各位大侠来看看,我头都大了!快帮帮呀!
- 租用国外的空间,用JSP写入MYSQL中的中文是“?”,救命啊!
char *dbhost_billing="127.0.0.1";
char *dbuser_billing="root";
char *dbpassword_billing="";
int dbport_billing=3306;
if ((ldap_billingd= mysql_init(NULL))==NULL)
{ printf("ldap_billingd: %s",mysql_error(ldap_billingd));
}
log("mysql_init is finished! \n");
if (mysql_real_connect(ldap_billingd,dbhost_billing,dbuser_billing,dbpassword_billing,"test",dbport_billing,NULL,0) <0)
{
printf("-----------------ldap_billingd: %s----------------",mysql_error(ldap_billingd));
}
printf("mysql_real_connect is finished! \n");
,"test",是数据库名
例如:
mysql_real_connect(&mysql,"localhost","root","dddd","test", 3306, NULL, 0)