List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:July 31 1999 2:31am
Subject:mysql_real_connect() fails
View as plain text  
>>>>> "Vasanthan" == Vasanthan Gunaratnam <vasg@stripped>
> writes:

Vasanthan> I have the following setup:
Vasanthan> - mysql server and client on same host
Vasanthan> - client program connects to server, performs queries, then quits

Vasanthan> Facts:

Vasanthan> 1. I have been using this system for ~3 months with no problems

Vasanthan> 2. I recently moved both server and client to new host and observed the
Vasanthan> following:
Vasanthan>     - client connects succesfully on first run/attempt
Vasanthan>    - subsequent connects (i.e. mysql_real_connect) fail the *majority*
Vasanthan> of the time
Vasanthan>     - shutdown of server and re-start enables the client to connect
Vasanthan> again, but only on the first
Vasanthan>        attempt

Vasanthan> 3. mysqladmin shows that the threads associated with a client's
Vasanthan> connection are terminated when
Vasanthan>    the client dies and attempts to re-connect

Vasanthan> 4. the mysql utility can connect to server when client program cannot

Vasanthan> 5. client (obviously) has permissions to connect (since it does so on
Vasanthan> the first attempt).

Vasanthan> 6.  the error number returned by mysql_real_connect() is 2003 and the
Vasanthan> error message generate is:
Vasanthan>     " Can't connect to MySQL server on 'localhost' (126)"


The above means that the problem is very likely in your operating
systems as the systam call 'connect' that fails with the error code:

(~) perror 126
Cannot assign requested address

The code that does this is:

   if (connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr))<0)
      DBUG_PRINT("error",("Got error %d on connect to '%s'",ERRNO,host));
      net->last_errno= CR_CONN_HOST_ERROR;
      sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, ERRNO);
      goto error;

You can of course trying to connect to sockets instead of connecting
with TCP/IP.  This could be a TCP/IP bug! 

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