List:General Discussion« Previous MessageNext Message »
From:Sasha Pachev Date:July 21 1999 4:40pm
Subject:Re: mysql_real_connect() fails
View as plain text  
Can you show the context of calling InitMysql() ?

What OS/MySQL configuration/compiler are you using on both machines?


> Client Code sniplets:
> ==============
> 
> static MYSQL mysql; /* only used by the one thread */
> 
> ...
> 
> static int InitMysql()
> {
> 
>  char *hostname=NULL;
>  char usernameIS[CS_MAXFILENAME]="userX";
>  char pwdIS[CS_MAXFILENAME]="userXpwd";
> 
> ...
> 
>      if (!mysql_init(&mysql))
>       {
>           fprintf(stderr,"Error: mysql_init() failed in.\n");
>           status = ERROR;
>       }
>        else if (!mysql_real_connect(&mysql, NULL, usernameIS, pwdIS,
> DATABASE_NAME, 0, NULL, 0))
>       {
>         fprintf(stderr, "Error: Failed to connect to database %s in: %s =>
> errorno(%d)\n", DATABASE_NAME,  mysql_error(&mysql),mysql_errno(&mysql));
>         status = ERROR;
>       }
> 
> ...
> 
>  return status;
> }
> 
> sinisa@stripped wrote:
> 
> > Vasanthan Gunaratnam writes:
> >  > I have the following setup:
> >  >
> >  > - mysql server and client on same host
> >  > - client program connects to server, performs queries, then quits
> >  >
> >  > Facts:
> >  >
> >  > 1. I have been using this system for ~3 months with no problems
> >  >
> >  > 2. I recently moved both server and client to new host and observed the
> >  > following:
> >  >     - client connects succesfully on first run/attempt
> >  >    - subsequent connects (i.e. mysql_real_connect) fail the *majority*
> >  > of the time
> >  >     - shutdown of server and re-start enables the client to connect
> >  > again, but only on the first
> >  >        attempt
> >  >
> >  > 3. mysqladmin shows that the threads associated with a client's
> >  > connection are terminated when
> >  >    the client dies and attempts to re-connect
> >  >
> >  > 4. the mysql utility can connect to server when client program cannot
> >  >
> >  > 5. client (obviously) has permissions to connect (since it does so on
> >  > the first attempt).
> >  >
> >  > 6.  the error number returned by mysql_real_connect() is 2003 and the
> >  > error message generate is:
> >  >     " Can't connect to MySQL server on 'localhost' (126)"
> >  >
> >  > 7. system seems to work ok when it is move back to the original/old host
> >  >


-- 
Sasha Pachev
http://www.sashanet.com/ (home)
http://www.direct1.com/ (work)
Thread
mysql_real_connect() failsVasanthan Gunaratnam20 Jul
  • mysql_real_connect() failssinisa20 Jul
  • Re: mysql_real_connect() failsSasha Pachev20 Jul
  • Re: mysql_real_connect() failsVasanthan Gunaratnam21 Jul
    • Re: mysql_real_connect() failssinisa21 Jul
  • Re: mysql_real_connect() failsVasanthan Gunaratnam21 Jul
    • Re: mysql_real_connect() failssinisa21 Jul
  • Re: mysql_real_connect() failsSasha Pachev21 Jul
  • Re: mysql_real_connect() failsVasanthan Gunaratnam21 Jul
  • mysql_real_connect() failsMichael Widenius31 Jul