By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
----- ----- -----
socket = /opt/mysql_root/sock/mysql.sock
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 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);


$dsn = "DBI:mysql:test;mysql_read_default_group=clien t;"
. "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==---- The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.