Hello all,

I've just joined to the list and I have a problem when I want to connect
to MySQL from my CGI when I'm running it through HTML.
This is my code:

    my %attr = (
        PrintError =>0,
        RaiseError =>0
                );

    $dbh = DBI->connect(
"DBI:mysql:array;mysql_read_default_file=$ENV{HOME}/.my.cnf",
                        "root",
                        "",
                         \%attr);
    if (defined($dbh)){
        print "\n Connected successfully", $DBI::errstr;
        $rc = STATUS_OK;
        $dbh->disconnect;
    }
    else {
        print "\n $DBI::errstr\n";
        $rc = undef;

    }

and this is my .my.cnf file:

[mysqld]
datadir=/homes/shoja/mysql/data
port=3309
socket=/tmp/mysql.sock.shoja

[client]
port=3309
socket=/tmp/mysql.sock.shoja

Now the problem is when I'm trying to run my cgi from command prompt there
is no error and it connect successfully.

But when I'm trying to run it through web browser I get this error
message:

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

and this is wondering because anyway my socket file is
'/tmp/mysql.sock.shoja'

so what is the problem.

Thank you all in advance for your help.

----------------------------------------------------------------------
Mohammadreza Shojatalab                              
European Bioinformatics Institute    Tel: +44 (0)1223 494 669                          
  
EMBL Outstation                      Fax: +44 (0)1223 494 468                          
  
Wellcome Trust Genome Campus         E-Mail: [EMAIL PROTECTED]                           
  
Hinxton, Cambridge                   URL: http://www.ebi.ac.uk/~shoja                  
  
CB10 1SD, UK


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