DBD:mysql doesn't read mysql option file /etc/my.cnf file

From: JL (crossin_at_istop.com)
Date: 01/28/05


Date: Thu, 27 Jan 2005 22:19:17 -0500

Platform: Linux Red Hat RHEL 3 (and red hat 9)

Installed MySQL from source. As a matter of fact, installed all LAMPS
from source, and the mysql socket file was arranged in a place other
than /tmp/mysql.sock. Let's say, /opt/mysql_root/sock/mysql.sock.
Installed DBI without any problem.

In /etc/my.cnf there are lines as
----- ----- -----
[client]
socket = /opt/mysql_root/sock/mysql.sock
...
[mysqld]
socket = /opt/mysql_root/sock/mysql.sock
...
----- ----- -----
The access rights issues to the directory was taken care off.

The problem came when installing DBD::mysql from source.

perl Makefile.Pl
make

make test => problem begins:

----- excerpt -----
...
...
... error: ..."can't connect to local mysql server through socket
/tmp/mysql.sock" ...
...

... [Error 2]

------ end ------

I have built everything from source, so there shouldn't be a problem of
"mysql server was built with binary and the others were built with
different packages, such as using the package from Linux o/s, etc."
And the mysqld was running while DBD installation was being progressed.

I didn't have problem with shell command line connecting to the server,
and code in PHP that connects to the server worked fine.

It seems that DBD::mysql doesn't (or doesn't have the intelligence to)
check /etc/my.cnf file when starting mysql client. I have tried

# ln -s /opt/mysql_root/sock/mysql.sock /tmp/mysql.sock

and the problem was solved. I prefer not to use this method.

Maybe rebuilding mysql with
"--with-unix-socket-path=/opt/mysql_root/sock/mysql.sock" will solve
the problem?

Or, setting shell variable
"MYSQL_UNIX_PORT=/opt/mysql_root/sock/mysql.sock" will do, too. So in
perl code, before we start db connection, we can set
$ENV{'MYSQL_UNIX_PORT'} = "/opt/mysql_root/sock/mysql.sock"?

I am trying to solve this problem at the system building phase, and to
avoid having to modify the original perl code, for example, from:

--
$dsn = "DBI:mysql:test";
$dbh = DBI->connect($dsn, $user, $password);
--
to
--
$dsn = "DBI:mysql:test;mysql_read_default_group=client;"
         . "mysql_read_default_file=/usr/local/mysql/data/my.cnf";
$dbh = DBI->connect($dsn, $user, $password);
--
so that the old perl code can be ported to the newly installed system 
without modification.
Appreciate your expertise
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


Relevant Pages

  • DBD:mysql doesnt read mysql option file /etc/my.cnf file
    ... Installed MySQL from source. ... ..."can't connect to local mysql server through socket ... And the mysqld was running while DBD installation was being progressed. ... avoid having to modify the original perl code, for example, from: ...
    (comp.lang.perl.misc)
  • DBD:mysql doesnt read mysql option file /etc/my.cnf file
    ... Installed MySQL from source. ... ..."can't connect to local mysql server through socket ... And the mysqld was running while DBD installation was being progressed. ... avoid having to modify the original perl code, for example, from: ...
    (comp.lang.perl.modules)
  • And the stupid question of the day that I cant figure out!
    ... I have an installation of OpenBSD 3.4 on a machine. ... installed mysql client and server. ... As specified by the mysql server install. ... command should really be: ...
    (comp.unix.bsd.openbsd.misc)
  • Re: DBD::mysql failing to make test
    ... I decided that, as a backup strategy for learning MySQL, I ... MySQL server installation. ... How to Protect or Change the MySQL Unix Socket File ... DBD::mysql installation would ultimately have succeeded without them. ...
    (perl.dbi.users)
  • Re: MySQL and Mac OSX
    ... MySQL is there. ... To test the installation, try logging in from the "terminal" program ... I had though MAMP would be an easier route to things when I ... the database you want to use for access with PHP if you hadn't created ...
    (alt.php)