I'm deploying a CGI script to a server with two mysql servers on it. My database exists and my user is privileged in the mysql5 server. But my connection attempt is throwing an error that DBI can't connect to the socket for the mysql4 server.

How do I make DBI look at the right server? Does it have to be rebuilt against the server? Is it possible to switch it with an argument fed to the DBI->connect() method? Is a port bound to that socket file? Is that how this works? I couldn't find a port assigned to this purpose in /etc/services. And I'm not root here. Any ideas how an unprivileged user might sort this one out, short of banging on every port to see if I can get in?

-- Hugh

UPDATE

Thank you Bart. I've tried that, although the sysadmin on this one tells me a socket connection at localhost will run w/o the network stack overhead involved in assigning a port.

Proving yet again the wisdom of my friend's sage advise to me that he never does any root work after 1am, and the wisdom of perhaps applying that to other areas of work . . .

Of course ps -aux gave me the port and socket, returning this as a part of the mysql lines: --port=3306 --socket=/var/src_apps/mysql5/mysqld.sock.

It revealed, in spite of my assumptions to the contrary, that only one server is now running, the my5 server. Even so, by adding or dropping the port from the $dsn string, I'm getting either of the following errors:

DBI connect('host=localhost;database=he_db','he_user',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) at /e6/run/cgi/supporters/vol.pm line 43

or

DBI connect('host=localhost;database=he_db;port=3306','he_user',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) at /e6/run/cgi/supporters/vol.pm line 43

as Carp fatalsToBrowser errors.

No longer stuck and confused on this one.

Oh, the wisdom one can find by the light of day:

It was as simple as appending to the end of the $dsn string, the following: ";mysql_socket=/var/src_apps/mysql5/mysqld.sock". Thanks to our sysadmin who found this documented in I believe DBD::mysql as I understood it.

if( $lal && $lol ) { $life++; }

In reply to Pointing DBI::DBD::mysql at right socket. by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.