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

Discussion in 'Perl' started by JL, Jan 28, 2005.

  1. JL

    JL Guest

    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 =---
     
    JL, Jan 28, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wes Gamble
    Replies:
    1
    Views:
    169
    Gerardo Santana Gómez Garrido
    Apr 5, 2006
  2. Andrew Crook

    DBD::CSV questions and is there a DBD::XML?

    Andrew Crook, Sep 2, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    177
    Andrew Crook
    Sep 11, 2003
  3. Mike Solomon

    DBD::mysqlPP v DBD::mysql

    Mike Solomon, Feb 16, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    230
    James Willmore
    Feb 16, 2004
  4. meneg
    Replies:
    2
    Views:
    123
    meneg
    Nov 17, 2004
  5. Jim Cochrane
    Replies:
    0
    Views:
    124
    Jim Cochrane
    Aug 25, 2007
Loading...

Share This Page