in reply to Perl Script connecting to Mysql works from command prompt, not from Apache

AHA! The httpd/error_log reports the following:
Sun Apr 15 01:12:49 2001 kk.pl: DBI->connect(Loader) failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) at /usr/www/loader/cgi-bin/kk.pl line 26

So the problem is a sockets problem
(Question: why would a command prompt execution use a different socket from the apache execution??)

Using find / -name mysql.sock yields it in /var/lib/mysql/mysql.sock. Since this is not where the error is I looked to see how mysql is configured by typing mysqladmin version. This is the result:

mysqladmin Ver 8.18 Distrib 3.23.35, for pc-linux-gnu on i686 Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB This software comes with ABSOLUTELY NO WARRANTY. This is free software +, and you are welcome to modify and redistribute it under the GPL licens +e Server version 3.23.35 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 29 min 46 sec Threads: 1 Questions: 1 Slow queries: 0 Opens: 6 Flush tables: 1 +Open tables: 0 Queries per second avg: 0.001

Clearly the server is configured correctly, so the problem must be one step pack, in the DBI or the DBD::mysql

I'm still hunting for where the /tmp/mysql.sock is specified, but I thought I'd give you this update.

  • Comment on Re: Perl Script connecting to Mysql works from command prompt, not from Apache
  • Download Code

Replies are listed 'Best First'.
Re: Re: Perl Script connecting to Mysql works from command prompt, not from Apache
by Yohimbe (Pilgrim) on Apr 15, 2001 at 21:04 UTC
    /tmp/myslq.sock will be what the DBI::DBD was compiled with. Had this problem too. I just symlinked /tmp/mysql.sock to the other one.
    --
    Jay "Yohimbe" Thorne, alpha geek for UserFriendly
      Dear Jay:

      Thanks! I was going nuts trying to figure out where that /tmp/mysql.sock was coming from. One small piece of further help please: How do I create the symlink? I've done this before and my recollection is that it is a simple command 2-4 characters long but that its name is not intuitive. My documentation shows that words with *link* in them tend to be include files for C programs. My RH 6.1 Bible does not mention symlink nor symbolik link nor alias, etc. for about a dozen different words I thought of.

      Do you know if the people in charge of DBI/DBD have any plans to make this a parameter? My recollection is that both MySQL and DBI use /tmp/mysql.sock. I had to go throiugh this process before just to het mysql to work from the command prompt. I have no idea where the /var/... socket came from.

      Regards,
      Gary

        The UNIX command you're looking for is ln -s ..... But you have to delete the existing socket first to replace it with a symlink, or use the additional option -f

        <per>-- Brigitte 'I never met a chocolate I didnt like' Jellinek http://www.horus.com/~bjelli/ http://perlwelt.horus.at
        Cool beans...:)

        I feel better now.

        the command you are looking for would be ln
        Snipped from the man page..

        NAME ln - make links SYNOPSIS ln [-fs] file [link_name] ln [-fs] file ... [directory] DESCRIPTION The ln utility creates a new directory entry, i.e. a new name in +the filesystem. There are two types of links: hard links and symboli +c links. ....
        EEjack