Ed Carp ([EMAIL PROTECTED]) writes:

> The obvious solution is to force, in the client library, for my.cnf to exist, 
>correctly configured, in a published place.  Any other ideas on how to solve this 
>problem?  I've already mentioned why relinking as a dynamic binary isn't feasible.

This won't fix existing systems and installations, obviously. Our workaround is to 
hard code places to look for mysql.sock:

char *where_socket[] = {
  "/tmp/mysql.sock",
  "/var/lib/mysql/mysql.sock",
  "/usr/local/lib/mysql/mysql.sock",
  NULL
};

[...]

  mysql_init (&mysql);
  mysql_options (&mysql, MYSQL_READ_DEFAULT_GROUP, "mysqld");
  if (!mysql_real_connect (&mysql, host, name, pass, db, 0, NULL, 0))
  {
    ptr = where_socket;
    while (*ptr != (char *) NULL)
    {
      if (mysql_real_connect (&mysql, host, name, pass, db, 0, *ptr, 0))
        break;
      if (mysql_errno (&mysql) != CR_CONNECTION_ERROR)
        printf ("<!-- ERROR %d connecting to database: %s -->\n",
                mysql_errno (&mysql), mysql_error (&mysql));
      ptr++;
    }
    if (*ptr == (char *) NULL)
    {
      fprintf (stderr, "ERROR %d connecting to database: %s\n",
               mysql_errno (&mysql), mysql_error (&mysql));
      return (EOF);
    }
  }

This is a hack because there are only so many places to look for mysql.sock and one 
can't hard-code them all, so this is only a short-term solution, and certainly one I 
wouldn't want to release in the engine!
--
Ed Carp, N7EKG  -  [EMAIL PROTECTED]  -  214/341-4420 - http://www.pobox.com/~erc

Squished Mosquito, Inc.
Internet Applications Development
Escapade Server-Side Scripting Language Development Team
http://www.squishedmosquito.com
Pensacola - Dallas - Dresden - London

---------------------------------------------------------------------
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

Reply via email to