MySQL C API problems

2005-03-25 Thread Andrew Prock

I'm having some difficulty with a program I wrote
which uses the MySQL C api.  I'm trying to migrate
my server from version 4.0 to version 4.1.

I have no difficulty connecting to the server using
the mysql.exe command line utility, but when I try to
connect from my program using the same parameters,
it fails to connect with the Error 1045 (Access denied
for user).

I use the mysqlclient.lib library to link to my
windows program.  The library I have is a bit old, but
I can't seem to figure out which version it is easily.

Is the solution as simple as getting the new developers
libraries?

Specific versions are below.

works with   : 4.0.16-standard server
doesn't work with: 4.1.7-standard  server



- Andrew

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: MySQL C API problems

2005-03-25 Thread Michael Stassen
Password hashing was changed in 4.1 to improve authentication security, but 
this complicates backward compatibility.  See the manual for details:
http://dev.mysql.com/doc/mysql/en/old-client.html
http://dev.mysql.com/doc/mysql/en/password-hashing.html

Your best bet is to link your app against the 4.1 client library.
Michael
Andrew Prock wrote:
I'm having some difficulty with a program I wrote
which uses the MySQL C api.  I'm trying to migrate
my server from version 4.0 to version 4.1.
I have no difficulty connecting to the server using
the mysql.exe command line utility, but when I try to
connect from my program using the same parameters,
it fails to connect with the Error 1045 (Access denied
for user).
I use the mysqlclient.lib library to link to my
windows program.  The library I have is a bit old, but
I can't seem to figure out which version it is easily.
Is the solution as simple as getting the new developers
libraries?
Specific versions are below.
works with   : 4.0.16-standard server
doesn't work with: 4.1.7-standard  server

- Andrew
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: MySQL C API problems

2005-03-25 Thread Andrew Prock
On Fri, 25 Mar 2005, Michael Stassen wrote:

 Password hashing was changed in 4.1 to improve authentication security, but
 this complicates backward compatibility.  See the manual for details:
 http://dev.mysql.com/doc/mysql/en/old-client.html
 http://dev.mysql.com/doc/mysql/en/password-hashing.html

 Your best bet is to link your app against the 4.1 client library.

I just tried this.  Or I think I did.  I uninstalled, and
reinstalled mysql v4.1.10a, which I assume has the 4.1
client library.  I recompiled, relinked, and I get the
same error.  Again, I can connect using the mysql CLI, it's
just connecting through the API which is giving me problems.

I can connect to the 4.1.1 server with the mysql CLI, but
only the 4.0 server with the API.  I did have to make one
minor change to the code to get it to recompile.  Is there
some other API issue which I need to be aware of?

The code I use to connect is:



  _mysqlconn = mysql_init (NULL);
  if (_mysqlconn == NULL)
{
  print_error (NULL, mysql_init() failed (probably out of memory));
  return -1;
}

  /* connect to server */
  if (mysql_real_connect (_mysqlconn, host_name, user_name, password,
  database_name, opt_port_num, opt_socket_name,
  opt_flags) == NULL)
{
  print_error (_mysqlconn, mysql_real_connect() failed);
  mysql_close (_mysqlconn);
  _mysqlconn = NULL;
  return -1;
}


And the failure occurs during mysql_real_connect with error 1045
Access denied for user: and not the

Client does not support authentication protocol requested
 by server; consider upgrading MySQL client

that the web-page indicates that I might expect.  Again, I
*can* connect with the mysql CLI, it is only from the API
where I'm having difficulty.

Referencing the web page, it appears that the 4.1 server is
using 16-byte passwords, and not the 41-byte passwords.  It
might be that the server was started with --old-passwords
option, but how can I find out if that is the case?

It might be that the API is generating long password values,
when I need short password values.  Can I control this behaviour
through the API?

- Andrew


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: MySQL C API problems

2005-03-25 Thread Andrew Prock
On Fri, 25 Mar 2005, Andrew Prock wrote:

 On Fri, 25 Mar 2005, Michael Stassen wrote:

  Password hashing was changed in 4.1 to improve authentication security, but
  this complicates backward compatibility.  See the manual for details:
  http://dev.mysql.com/doc/mysql/en/old-client.html
  http://dev.mysql.com/doc/mysql/en/password-hashing.html
 
  Your best bet is to link your app against the 4.1 client library.

Thank you for your assitance.  I have determined that
amidst all my horrid code there is a bug that is
totally unrelated to MySQL, and it's version number,
but that was related to port numbers.  Since both
servers are at the same domain, they are accessed
through different ports, and while I thought I was
handling ports correctly, I was always using the
default port.

Thanks again,

- Andrew


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Mysql C API problems

2002-06-29 Thread Hugo Veiga

hi there 

the present serves for some clearing some doubts i have: 

1 - if i wanna make an action based on the fact that a query i just made 
won't return results (empty set), how can i test that? 

will this do? 
if(!mysql_query(myData, query) 
{ 
   results = mysql_store_results(myData); 

   if(mysql_num_rows() == 0) 
   { 
   //action; 
   } 
} 

2 - if the the row is made of one single field wich in turn is an integer, 
how can i address to it's value? 

will this do? 
row = mysql_fetch_row( results ); 

if(row[0]!=NULL) 
{ 
tempo=_registo[0]-decimals; //?!??!?!? 
//other actions here
}//if 

thank u in advance, 
Compliments 




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Mysql C API problems

2002-06-29 Thread Dean Harding

 1 - if i wanna make an action based on the fact that a query i just
made 
 won't return results (empty set), how can i test that? 

 will this do? 
 if(!mysql_query(myData, query) 
 { 
results = mysql_store_results(myData); 

if(mysql_num_rows() == 0) 
{ 
//action; 
} 
 } 

That's right, except mysql_num_rows() takes a pointer to the results you
get from mysql_store_results(), so it looks like this:

if( mysql_num_rows( result ) == 0 )
{
// action
}

 2 - if the the row is made of one single field wich in turn is an
integer, 
 how can i address to it's value? 

Like this:

MYSQL_ROW row = mysql_fetch_row( result );
int value = atoi( row[0] );

Dean Harding


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Mysql C API problems

2002-06-29 Thread Georg Richter

On Saturday, 29. June 2002 11:15, Hugo Veiga wrote:

Hello Hugo,

 will this do?
 if(!mysql_query(myData, query)
 {
results = mysql_store_results(myData);

-if(mysql_num_rows() == 0)
+if (!mysql_num_rows(results))
{
//action;
}
 }

with the above correction it should work :)

 will this do?
 row = mysql_fetch_row( results );

 if(row[0]!=NULL)
 {
 tempo=_registo[0]-decimals; //?!??!?!?
 //other actions here
 }//if


The values in row are always represented as strings, so you have to use atoi, 
atol, atof depends on the type, to convert it:

if ((row = mysql_fetch_row(results)) != NULL) {
  tempo = atoi(row[0]); 
}

Regards Georg

mysql, query

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php