<?xml version="1.0" encoding="windows-1252"?>
<node id="472574" title="Connecting to mysql using DBI and a non-standard socket" created="2005-07-05 15:34:23" updated="2005-07-26 19:44:23">
<type id="115">
perlquestion</type>
<author id="150245">
logan</author>
<data>
<field name="doctext">
I've been bashing my head against this wall for two days and making no progress. I have a mysql database on a local Linux server and I'm trying to connect using DBI. The socket location is nonstandard. Instead of "/var/lib/mysql/mysql.sock", it's "/usr/kasenna/mysql/tmp/mysql.sock". 
&lt;p&gt;
From the command line, I can connect using DBI:&lt;p&gt;
&lt;code&gt;mysql -S /usr/kasenna/mysql/tmp/mysql.sock -u root --password=password&lt;/code&gt;. &lt;p&gt;
When I try to duplicate that using DBI:&lt;p&gt;
&lt;code&gt;my $dbh = DBI-&gt;connect('dbi:mysql:database=nemo;socket=/usr/kasenna/mysql/tmp/mysql.sock', 'nemo','password')&lt;/code&gt; &lt;br&gt;
or
&lt;code&gt;
my %attr;
$attr{socket} = "/usr/kasenna/mysql/tmp/mysql.sock";
my $dbh = DBI-&gt;connect('dbi:mysql:nemo', 'nemo', 'password', \%attr);
&lt;/code&gt;I get the following error:&lt;br&gt;

&lt;code&gt;Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)&lt;/code&gt;
&lt;p&gt;
I'm pretty sure that the problem stems from trying to pass the non-standard socket location, but I can't figure out how to pass that in the connect statement. 
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-150245"&gt;
&lt;p&gt;
-Logan&lt;br&gt;
"What do I want? I'm an American. I want more."
&lt;/div&gt;&lt;/div&gt;</field>
</data>
</node>
