List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 19 2000 9:11pm
Subject:Re: Still Can't Connect to MySQL using PERL
View as plain text  
At 1:40 PM -0500 2000-02-19, Laszlo G. Szijarto wrote:
>Thank you very much, Mr. Dubois.  PS -- I did buy your book.  It was
>excellent, though I haven't had time to read it cover to cover yet.  Option
>2 worked.  Option 1 did not.  Do you have any ideas why not?  I copied the
>my.conf-sample file to /etc as my.cnf with the requisite lines included, but
>did the mysqld not read it when it started up?  I would prefer that this be
>a global option rather than having to include the socket specification in
>every PERL script I write.
>Thank you again,
>Laszlo Szijarto


I agree, a global setting would be better.

I forgot that Perl clients don't read option files by default - you need
to tell them to do so.  One way to do that is like this:

$dsn = "DBI:mysql:db_name:localhost;mysql_read_named_group=client";

This will cause the connection routine to look in the standard option
files (/etc/my.cnf, ~/.my.cnf) for options listed in the [client]
option group.


With respect to the server, it does read /etc/my.cnf when it starts
up, but it doesn't look at the [client] option group, because it's
not a client.  You could tell it explicitly where the socket file
should be like this:

[mysqld]
socket=/var/lib/mysql/mysql.sock

But that's probably unnecessary, because it appears that that is where
the server is creating the socket now.  It might be useful to set
the socket pathname in both the [mysqld] and [client] option groups
if you want to put the socket somewhere other than in /var/lib/mysql.
Restart the server if you do this so that it re-reads /etc/my.cnf.


>  > Here are a couple of things you can try.
>>
>>  1) If you have access to /etc/my.cnf, put this in it:
>>
>>  [client]
>>  socket=/var/lib/mysql/mysql.sock
>>
>>  (If you already have a [client] option group in /etc/my.cnf,
>>  just add the socket line to it.)  This will cause all client
>>  programs on the machine to use the named socket path for connections
>>  to localhost.
>>
>>  2) In your data source name in your Perl script, use a value like
>>  this:
>>
>
>  > $dsn =
>"DBI:mysql:db_name:localhost;mysql_socket=/var/lib/mysql/mysql.sock";
>>
>>  (Note: it's s semi-colon before "mysql_socket", not  a colon.)
>>  This will use the named socket on a per-script basis.
>>
>>
>>  >----- Original Message -----
>>  >From: "Jeremy Gaddis" <jgaddis@stripped>
>>  >To: "Laszlo G. Szijarto" <lszijarto@stripped>
>>  >Cc: <mysql@stripped>
>>  >Sent: Friday, February 18, 2000 8:27 PM
>>  >Subject: Re: Stil Can't Connect To MySQL using PERL
>>  >
>>  >
>>  >>  At 05:13 PM 2/18/00 -0500, Laszlo G. Szijarto wrote:
>>  >>
>>  >>  > mysql.pm into a location that PERL 5.003 cannot find.
>>  >>  > perl-Msql-Mysql-modules >installs in a location that
>>  >>  > PERL can find, but I get the cannot connect at
>>  >>  > /tmp/mysql.sock (111) error.  I got all the MySQL rpms
>>  >>
>>  >>  If you do:
>>  >>
>>  >>  [jgaddis@gatekeeper:ttyp0:~]$ ls -l /tmp/mysql.sock
>>  >>
>>  >>  do you get something similar to:
>>  >>
>>  >>  srwxrwxrwx   1 root     root            0 Feb  6 22:55
> /tmp/mysql.sock
>>  >>
>>  >>  If not, that's your problem.  Some distributions put
>>  >>  the socket file in other locations.  If it's not in
>>  >>  /tmp, do `find / -name mysql.sock`, and you should
>>  >>  be able to find it.  I just found another one in
>>  >>  /var/lib/mysql/mysql.sock, so you might check there.
>>  >>
>>  >>  HTH,
>>  >>
>>  >>  --
>>  >>  Jeremy Gaddis              <jgaddis@stripped>
>>  >>
>>  >>
>>  >
>>
>>
>>  --
>>  Paul DuBois, paul@stripped
>>
>>  --
>>  ---------------------------------------------------------------------
>>  Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>>  posting. To request this thread, e-mail mysql-thread28328@stripped
>>
>>  To unsubscribe, send a message to:
>>      <mysql-unsubscribe-szijarto=ncdcorp.com@stripped>
>>
>


-- 
Paul DuBois, paul@stripped
Thread
Re: Still Can't Connect to MySQL using PERLLaszlo G. Szijarto19 Feb
  • Re: Still Can't Connect to MySQL using PERLVan19 Feb
  • Re: Still Can't Connect to MySQL using PERLPaul DuBois19 Feb
  • Re: Still Can't Connect to MySQL using PERLLaszlo G. Szijarto19 Feb
    • Re: Still Can't Connect to MySQL using PERLPaul DuBois20 Feb
Re: Still Can't Connect to MySQL using PERLEd Carp19 Feb
  • Re: Still Can't Connect to MySQL using PERLPaul DuBois20 Feb
Re: Still Can't Connect to MySQL using PERLEd Carp19 Feb