哎呦我了个曹,我贴的你没看吗?

    $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";

    $dbh = DBI->connect($dsn, $user, $password);

http://search.cpan.org/~capttofu/DBD-mysql-4.022/lib/DBD/mysql.pm




2013/2/1 Haiyan Lin <linhy0...@gmail.com>

>  代码如下,
>
> #!/usr/bin/perl
> use DBI;
> my $dbh =
> DBI->connect("dbi:mysql:host=localhost:datase=seedBase:mysql_socket=/tmp/mysql.sock",'user','password',
> {'RaiseError' => 1}) or die $!  ;
>
> print "Content-type: text/plain\n\n";
> print "mod_perl 2.0 rocks! \n";
>
>
> 错误是:
>
> [Fri Feb 01 16:42:11 2013] [error] DBI
> connect('host=localhost:database=seedBase:mysql_socket=/tmp/mysql.sock','apache',...)
> failed: Can't connect to local MySQL server through socket
> '/tmp/mysql.sock' (2) at /var/www/perl/rock.pl line 4\n
>
>
>
>
>
>
>
>
> On 01/30/2013 10:09 PM, wd wrote:
>
> 还是一样是什么意思?还是报下面这个错误?贴你的代码和错误看看
> Can't connect to local MySQL server through socket '/tmp/mysql.sock'
>
>
> 2013/1/30 Haiyan Lin <linhy0...@gmail.com>
>
>>  试过port=3306,但还是一样,防火墙的3306是开着的
>>
>>
>> On 01/30/2013 11:00 AM, wd wrote:
>>
>>      $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
>>
>>     $dbh = DBI->connect($dsn, $user, $password);
>>
>> http://search.cpan.org/~capttofu/DBD-mysql-4.022/lib/DBD/mysql.pm
>>
>>
>>
>>  2013/1/30 Haiyan Lin <linhy0...@gmail.com>
>>
>>>  用TCP端口连,要怎么操作啊
>>>
>>>
>>>
>>> On 01/30/2013 10:26 AM, wd wrote:
>>>
>>>   呃。。为啥一定要用 socket 连接呢?。。。
>>> 通过 tcp 端口不也挺好么。。
>>>
>>>
>>> 2013/1/30 夏凯 <walke...@gmail.com>
>>>
>>>>  On 2013年01月30日 10:06, Haiyan Lin wrote:
>>>>
>>>>> 怎么打印啊
>>>>>
>>>>> print join "\n", (`ls /`)
>>>>>
>>>>> 吗?
>>>>>
>>>>  应该这样就可以了,不过最好用File::Spec来看下/下面的文件, 然后根据这个确 认下是被chroot到哪个目录,再把mysql的
>>>> sock改到那个目录下,就能连接了。
>>>>  比如apache把/给chroot到/data,那么你在apache访问 /tmp /mysql.sock实际上是 访问磁盘上的/data
>>>> /tmp/mysql.sock。
>>>>
>>>> 或者直接用-e /tmp/mysql.sock看下文件是否存在,这样可以确认是不是被chroot了。
>>>>
>>>>
>>>> --
>>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>>>> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 perlchina+unsubscr...@googlegroups.com。
>>>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
>>>> 通过以下网址访问此论坛:http://groups.google.com/group/perlchina?hl=zh-CN。
>>>> 要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
>>>>
>>>>
>>>>
>>>   --
>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>>> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 perlchina+unsubscr...@googlegroups.com。
>>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
>>>     通过以下网址访问此论坛:http://groups.google.com 
>>> /group/perlchina?hl=zh-CN。<http://groups.google.com/group/perlchina?hl=zh-CN%A1%A3>
>>> 要查看更多选项,请访问 https://groups.google.com 
>>> /groups/opt_out。<https://groups.google.com/groups/opt_out%A1%A3>
>>>
>>>
>>>
>>>
>>>    --
>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>>> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 perlchina+unsubscr...@googlegroups.com。
>>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
>>> 通过以下网址访问此论坛:http://groups.google.com/group 
>>> /perlchina?hl=zh-CN。<http://groups.google.com/group/perlchina?hl=zh-CN%A1%A3>
>>> 要查看更多选项,请访问 https://groups.google.com/groups 
>>> /opt_out。<https://groups.google.com/groups/opt_out%A1%A3>
>>>
>>>
>>>
>>
>>   --
>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 perlchina+unsubscr...@googlegroups.com。
>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
>> 通过以下网址访问此论坛:http://groups.google.com 
>> /group/perlchina?hl=zh-CN。<http://groups.google.com/group/perlchina?hl=zh-CN%A1%A3>
>> 要查看更多选项,请访问 https://groups.google.com 
>> /groups/opt_out。<https://groups.google.com/groups/opt_out%A1%A3>
>>
>>
>>
>>
>>   --
>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 perlchina+unsubscr...@googlegroups.com。
>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
>> 通过以下网址访问此论坛:http://groups.google.com/group 
>> /perlchina?hl=zh-CN。<http://groups.google.com/group/perlchina?hl=zh-CN%A1%A3>
>> 要查看更多选项,请访问 https://groups.google.com/groups 
>> /opt_out。<https://groups.google.com/groups/opt_out%A1%A3>
>>
>>
>>
>
>  --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 perlchina+unsubscr...@googlegroups.com。
> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
> 通过以下网址访问此论坛:http://groups.google.com 
> /group/perlchina?hl=zh-CN。<http://groups.google.com/group/perlchina?hl=zh-CN%A1%A3>
> 要查看更多选项,请访问 https://groups.google.com 
> /groups/opt_out。<https://groups.google.com/groups/opt_out%A1%A3>
>
>
>
>
>  --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 perlchina+unsubscr...@googlegroups.com。
> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
> 通过以下网址访问此论坛:http://groups.google.com/group/perlchina?hl=zh-CN。
> 要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
>
>
>

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 perlchina+unsubscr...@googlegroups.com。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
通过以下网址访问此论坛:http://groups.google.com/group/perlchina?hl=zh-CN。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。


回复