hesco has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting a DBI->connect error, reading: "Can't connect to local MySQL server through socket" and identifying a socket other than the one listed in /etc/mysql/my.cnf. Is there anyway without root access to address this?

Thanks smiffy. That was appreciated. Don't know why I didn't find that when searching perldoc.

-- Hugh

UPDATE: Sorry, should have mentioned. A search of the DBI perldoc revealed no use of the word, 'socket'. Any idea how to do that, please?

if( $lal && $lol ) { $life++; }
  • Comment on DBI connection issue, looking in all the wrong sockets . . .

Replies are listed 'Best First'.
Re: DBI connection issue, looking in all the wrong sockets . . .
by smiffy (Pilgrim) on Sep 30, 2008 at 21:49 UTC

    I'd guess that you have run into the problem where a MySQL upgrade has moved the socket to /tmp/mysql.sock.

    To clarify kubrat's response, here is an example based on my own setup:

    my $dbh=DBI->connect('dbi:mysql:database=foo; host=localhost; mysql_so +cket=/var/run/mysqld/mysqld.sock', 'myuser', 'myuserpass');

    You can also set an environment variable before making your connection (without specifying the socket):

    $ENV{MYSQL_UNIX_PORT}='/var/run/mysqld/mysqld.sock'; my $dbh=DBI->connect('dbi:mysql:database=foo; host=localhost', 'myuser +', 'myuserpass');

    Putting this in as a DBI connection parameter is much neater though.

    Hope this helps.

Re: DBI connection issue, looking in all the wrong sockets . . .
by kubrat (Scribe) on Sep 30, 2008 at 19:58 UTC

    How about changing the dbi connect parameters to match those of the configuration file?