MySQL Forums
Forum List  »  Newbie

Can't get C API to recognize Option File
Posted by: David Johnson
Date: August 16, 2004 05:00PM

In spite of many different calls to mysql_options(), I have not
been able to get the C API to recognize an Option File. I have
also tried many different calls to mysql_real_connect(). I can
use the standard ~/.my.cnf with the mysql client, but the only way
I can get to my data with the C API is to "hard code" user and
password values into the mysql_real_connect() call. The error
message I get with the C API is:
Access denied for user: 'ccnjdcj@localhost' (Using password: NO)

Here are snippets of code I have tried:
===============================================================
mysql_init(&mysql);
/************************* OPTIONS TO TRY
strcpy(line, argv[0]);
strcpy(line, "client");
strcpy(line, "myslistdb");
strcpy(line, "");
strcpy(line, "qzjxv");
***************************/
strcpy(line, "client");
res = mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP, line);
if (res != 0) {
printf (" FAILED mysql_options = %d for Grp=%s\n", res, line);
}
/************************* OPTIONS TO TRY
if (!mysql_real_connect(&mysql,hostname,"","","",0,NULL,0)) {
if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0)) {
if (!mysql_real_connect(&mysql,"","","","",0,NULL,0)) {
if (!mysql_real_connect(&mysql,"localhost","ccnjdcj","","",0,NULL,0)) {
***************************/
if (!mysql_real_connect(&mysql,"","","","",0,NULL,0)) {
fprintf(stderr, "Failed to connect to database: Error= %s\n",
mysql_error(&mysql));
} else {
fprintf(stderr, "Successful connect to MySQL Server %s\n", p);
}
===============================================================

Options: ReplyQuote


Subject
Written By
Posted
Can't get C API to recognize Option File
August 16, 2004 05:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.